View Code of Problem 50

#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
#include <iomanip>
#include<vector>
#include<math.h>
using namespace std;
int main()
{
	string s1;
	string s2;
	getline(cin, s1);
	int j = 0;
	int flag = 1;
	for (int i = 0; i < s1.length(); i++) {
		if ((s1[i] > '9'||s1[i] < '0')&&flag== 1) {
			s2 = s2 + '*';
			flag = 0;
		}
		if (s1[i] <= '9' && s1[i] >= '0') {
			s2 = s2+s1[i];
			flag = 1;
		}
	}
	cout << s2;
}

Double click to view unformatted code.


Back to problem 50