View Code of Problem 50

#include<iostream>
#include<map>
#include<cmath>
using namespace std;
int main(){
	string str1;
	while(getline(cin,str1)){
		string str2="";
		//状态位 
		for(int i=0;i<str1.length();i++){
			if(str1[i]>='0'&&str1[i]<='9'){
				str2=str2+str1[i];
			}else{
				str2=str2+"*";
			}
		}
		//然后把str2进行输出
		
		for(int j=0;j<=str2.length();j++){
			if(str2[j]>='0'&&str2[j]<='9'){
				printf("%c",str2[j]);
			}else if((str2[j]=='*')&&(str2[j+1]!='*')){
				printf("*");
			}
		} 
		cout<<endl;
		
	return 0;
	}
}

Double click to view unformatted code.


Back to problem 50