Advertisement
malixds_

Untitled

Nov 8th, 2021
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     setlocale(LC_ALL, "ru");
  8.     ifstream f;
  9.     int arr[10];
  10.     int sum = 0;
  11.     f.open("C:\\sum.txt", ios::in);
  12.     if (f.is_open()) {
  13.         for (int i = 0; i <= 9; i++) {
  14.             cout << "Введите " << i + 1 << " число:";
  15.             cin >> arr[i];
  16.         }
  17.         for (int i = 0; i < 10; ++i) {
  18.             sum += arr[i];
  19.         }
  20.     }
  21.     ofstream fin;
  22.     fin.open("C:\\sum.txt");
  23.     fin << sum;
  24.     fin.close();
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement