There was an error while loading. Please reload this page.
1 parent cd2bf40 commit 4835bb4Copy full SHA for 4835bb4
Online Judges/URI/1120.cpp
@@ -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
23
+ }
24
25
26
+ if (cin.peek() == '\n')
27
+ break;
28
29
30
+ if (s == "0" && d == '0')
31
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