Facebook
From Soft Goose, 6 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 247
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstdlib>
  4. #include<time.h>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.         int a;
  11.         int suma = 0;
  12.         int x;
  13.         ifstream odczyt;
  14.         odczyt.open("rosnace.txt");
  15.         if(odczyt)
  16.         {
  17.                
  18.                 odczyt >> x;
  19.                
  20.                 while(!odczyt.eof())
  21.                 {
  22.                         odczyt >> a;
  23.                         suma = suma+a;
  24.                        
  25.                        
  26.                        
  27.                 }
  28.         odczyt.close();
  29.         }else
  30.         {
  31.                 cout << "Nie udalo sie odczytac pliku" << endl;
  32.         }
  33.         cout << "Suma liczb wynosi" << suma << endl;
  34. }