SHARE
TWEET

Untitled

a guest May 24th, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3. #include <ctime>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int tab[10];
  10.     int wynik=0;
  11.     ofstream liczby;
  12.     liczby.open("trzytys.txt");
  13.     srand(time(NULL));
  14.     for(int k=0; k<10; k++)
  15.     {liczby<<rand()<<endl;}
  16.     liczby.close();
  17.  
  18.     ifstream odczyt;
  19.     odczyt.open("trzytys.txt");
  20.     for(int k=0; k<10; k++)
  21.     {odczyt>>tab[k];}
  22.     odczyt.close();
  23.    
  24.     ofstream suma;
  25.     suma.open("sumaliczb.txt");
  26.     for(int k=0; k<10; k++)
  27.        { while(tab[k]!=0)
  28.         {
  29.             wynik=wynik+tab[k]%10;
  30.             tab[k]=tab[k]/10;
  31.         }
  32.            suma<<wynik<<endl;
  33.        }
  34.     suma.close();
  35.    
  36.     return 0;
  37.    
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top