View Code of Problem 50

#include<iostream>
using namespace std;
int main(){
	string str1;
	string str2;
	bool flag=true;
	getline(cin,str1);
	for(int i=0;i<str1.length();i++){
		if(flag==true && (str1[i]<'0' || str1[i]>'9')){
			str2.push_back('*');
			flag=false;
		}
		else if(str1[i]>='0' && str1[i]<='9'){
			flag=true;
			str2.push_back(str1[i]);
		}
	}
	cout<<str2<<endl;
}

Double click to view unformatted code.


Back to problem 50