-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy path1120.cpp
53 lines (46 loc) · 1.21 KB
/
1120.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
43
44
45
46
47
48
49
50
51
52
53
#include <stdio.h>
#include <iostream>
#include <sstream>
int main(){
int n, i, j, zero, cont;
long long int num;
char number[101];
while(std::cin >> n){
scanf("%s",number);
if(n == 0 && number[0] == '0') break;
char changed[101];
i = 0;
j = 0;
zero = 0;
num = 0;
cont = 0;
while(true){
if(number[i] == '\0'){
break;
}
else if(number[i] == n+48){
i++;
}
else{
changed[j] = number[i];
if(j == zero) cont++;
if(number[i] == '0') zero++;
i++;
j++;
}
}
changed[j] = '\0';
std::stringstream f(changed);
f >> num;
if(j == 0){ printf("0\n"); }
else if(j == zero){ printf("%lld\n", num); }
else if(cont > 0){
for(int k = cont-1; changed[k] != '\0'; k++){
printf("%d",changed[k]-48);
}
printf("\n");
}
else printf("%s\n", changed);
}
return 0;
}