int main() { string a, b, c, d; int n, m; while (cin >> n >> m) { int count = 0; cin >> a >> b; int x = gcd(n, m); int tempn = n / x; int tempm = m / x; while (tempn--) { c += a; } while (tempm--) { d += b; } for (int i = 0;i < c.length();i++) { if (c[i] != d[i]) { count++; } } printf("%d\n", count*x); } } /* Main.cc: In function 'int main()': Main.cc:2:2: error: 'string' was not declared in this scope string a, b, c, d; ^~~~~~ Main.cc:2:2: note: suggested alternative: 'struct' string a, b, c, d; ^~~~~~ struct Main.cc:4:9: error: 'cin' was not declared in this scope while (cin >> n >> m) { ^~~ Main.cc:4:9: note: suggested alternative: 'main' while (cin >> n >> m) { ^~~ main Main.cc:6:10: error: 'a' was not declared in this scope cin >> a >> b; ^ Main.cc:6:15: error: 'b' was not declared in this scope cin >> a >> b; ^ Main.cc:7:11: error: 'gcd' was not declared in this scope int x = gcd(n, m); ^~~ Main.cc:11:4: error: 'c' was not declared in this scope c += a; ^ Main.cc:14:4: error: 'd' was not declared in this scope d += b; ^ Main.cc:16:22: error: 'c' was not declared in this scope for (int i = 0;i < c.length();i++) { ^ Main.cc:17:16: error: 'd' was not declared in this scope if (c[i] != d[i]) { ^ Main.cc:21:3: error: 'printf' was not declared in this scope printf("%d\n", count*x); ^~~~~~ Main.cc:21:3: note: 'printf' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'? Main.cc:1:1: +#include <cstdio> int main() { Main.cc:21:3: printf("%d\n", count*x); ^~~~~~ */ |
Double click to view unformatted code.