Advertisement
Kolyach

4.1

Nov 11th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <iostream>
  4. #include <cmath>
  5. #include <fstream>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.    setlocale(LC_ALL, "russian");
  12.  
  13.    fstream F;
  14.    F.open("kpop.txt",ios::out);
  15.    int a;
  16.    for (int i=0; i<10; i++){
  17.     cin >> a;
  18.     F << " " << a;
  19.    }
  20.    F.close();
  21.  
  22.    int sum, X;
  23.    sum=0;
  24.    F.open("kpop.txt",ios::in);
  25.    while (!F.eof()){
  26.     F >> X;
  27.     sum=sum+X;
  28.    }
  29.     cout << sum;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement