Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void thirdTask() {
- ofstream file("sum.txt");
- cout << "Введите число:";
- long long t;
- ENT:
- cin >> t;
- if (cin.fail()) {
- defeat();
- cout << "Введено не число!" << endl;
- goto ENT;
- }
- defeat();
- file << t;
- file << " ";
- file.close();
- long long sum = 0;
- ifstream in("sum.txt");
- string line;
- getline(in, line);
- long long chislo = stoi(line);
- for (int i = 0; i < line.size(); i++) {
- sum += chislo % 10;
- chislo /= 10;
- }
- cout << "Сумма цифр в числе: " << sum << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement