View Code of Problem 50

#include<iostream>
#include<string>
using namespace std;

int isletter(char c) {
	if (c>='0'&&c<='9') {
		return 1;
	}
	else {
		return 0;
	}
}
int main() {
	string str1;
	string str2;
	cin >> str1;
	for (int i = 0; i < str1.size()-1; i++) {
		if (isletter(str1[i])==1) {
			str2.push_back(str1[i]);
		}
		else if (isletter(str1[i]) == 0 && isletter(str1[i + 1]) == 1) {
			str2.push_back('*');
		}
	}
	if (isletter(str1[str1.size() - 1]) == 0) {
		str2.push_back('*');
	}
	else {
		str2.push_back(str1[str1.size() - 1]);
	}
	for (int i = 0; i < str2.size(); i++) {
		cout << str2[i];
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 50