View Code of Problem 50

#include <bits/stdc++.h>
using namespace std;
vector<char>arr;
int main(){
	string str1;
	getline(cin,str1);
	for(int i=0;i<=str1.length();i++)
	{
		if(str1[i]>='0'&&str1[i]<='9')
		{
			arr.push_back(str1[i]);
		}
		else{
			for(int j=i;j<str1.length();j++){
				if(str1[j]>='0'&&str1[j]<='9')
				{
					i=j-1;
					arr.push_back('*');
					break;
				}

			
			}
			
		}
	}
	for (int i = 0; i < arr.size(); ++i) {
        cout << arr[i];
    }
      if(str1[str1.length() - 1]>='0'&&str1[str1.length() - 1]<='9'){
   	return 0;
   }
   else{
   		cout<<"*";
   }
}

Double click to view unformatted code.


Back to problem 50