2022/sector/10/sum solution

This commit is contained in:
2025-04-23 18:44:49 +03:00
parent 30f71c5604
commit 4240590f22

View File

@@ -0,0 +1,25 @@
#include <bits/stdc++.h>
using namespace std;
ifstream in("test.in");
ofstream out("test.out");
int main() {
int sum = 0;
char prevSymbol = '+';
for (char symbol; in >> symbol;) {
if (symbol == prevSymbol) {
cout << "error" << endl;
return 0;
}
if (symbol != '+') {
sum += symbol - '0';
}
prevSymbol = symbol;
}
cout << sum << endl;
return 0;
}