Advertisement
kaunas163

Random skaičiai

Feb 17th, 2014
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <stdlib.h>
  4. #include <time.h>
  5. using namespace std;
  6.  
  7. void GeneruojaIrSpausdina(int kiek);
  8.  
  9. int main() {
  10.     setlocale(LC_ALL, "Lithuanian");
  11.     int kiek;
  12.     cout << "Kiek eilučių reikia? ";
  13.     cin >> kiek;
  14.     cout << endl;
  15.     GeneruojaIrSpausdina(kiek);
  16.     system("pause");
  17.     return 0;
  18. }
  19.  
  20. void GeneruojaIrSpausdina(int kiek) {
  21.     ofstream fout("Skaiciai.txt");
  22.     int a;
  23.     srand(time(NULL));
  24.  
  25.     for (int i = 0; i < kiek; i++)
  26.     {
  27.         for (int i = 0; i < 8; i++)
  28.         {
  29.             a = rand() % 10;
  30.             fout << a;
  31.         }
  32.         fout << endl;
  33.     }
  34.     cout << "Skaičiai išvesti į failą Skaiciai.txt\n\n\n";
  35.     fout.close();
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement