Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4835bb4

Browse files
accepted
1 parent cd2bf40 commit 4835bb4

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

‎Online Judges/URI/1120.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include <iostream>
2+
#include <cstdio>
3+
4+
using namespace std;
5+
6+
int main() {
7+
char d;
8+
char c;
9+
10+
while(cin >> d) {
11+
char ch;
12+
string s = "";
13+
bool previouswaszero = false;
14+
while (cin >> ch) {
15+
16+
if (ch != d) {
17+
if (ch == '0' && !previouswaszero) {
18+
previouswaszero = true;
19+
s+=ch;
20+
} else if (ch != '0') {
21+
previouswaszero = false;
22+
s+=ch;
23+
}
24+
}
25+
26+
if (cin.peek() == '\n')
27+
break;
28+
}
29+
30+
if (s == "0" && d == '0')
31+
break;
32+
33+
string c = "";
34+
if (s[0] == '0' && (int)s.size() >= 2) {
35+
for (int i = 1; i < (int)s.size(); i++) {
36+
c+=s[i];
37+
}
38+
s = c;
39+
}
40+
41+
if (s == "")
42+
s = "0";
43+
cout << s << endl;
44+
}
45+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /