-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path1120 - Contract Revision.cpp
42 lines (41 loc) · 1.02 KB
/
1120 - Contract Revision.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <bits/stdc++.h>
using namespace std;
int main()
{
char d;
string n;
while(cin >> d >> n){
if(n == "0" && d == '0') break;
int len = n.length();
string s;
for(int i = 0 ; i < len; i++){
if(n[i] == d) continue;
s += n[i];
}
int zero = 0;
bool iszero = false;
for(int i = 0 ; i < s.length() ; i++){
if(s[i] != '0'){
iszero= false;
break;
}
else{
iszero = true;
zero++;
}
}
if(iszero == true || s.empty()) cout << 0 << endl;
else if(zero > 0){
string ss;
bool nonzero = false;
for(int i = 0 ; i < s.length(); i++){
if(s[i] != '0') nonzero = true;
if(s[i] == '0' && nonzero == false) continue;
ss += s[i];
}
cout << ss << endl;
}
else cout << s << endl;
}
return 0;
}