Vla_DOS

Untitled

May 12th, 2022
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <locale>
  4. #include <cstdlib>
  5. #include <fstream>
  6. #include <string>
  7. #include <algorithm>
  8. using namespace std;
  9.  
  10. int main()
  11. {
  12.     setlocale(0, "");
  13.     ofstream fout("output.txt");
  14.     int N, k;
  15.     cout << "Введiть кiлькiсть чисел:" << endl;
  16.     cin >> N;
  17.     int* A = new int[N];
  18.     k = 0;
  19.     for (int i = 0; i < N; i++)
  20.     {
  21.         A[i] = rand() % 101;
  22.         if (((int)sqrt(A[i]) == sqrt(A[i])) && (A[i] % 2)) k++;
  23.         fout << A[i] << " ";
  24.  
  25.     }
  26.     fout.close();
  27.    
  28.     string line;
  29.     ifstream in("output.txt");
  30.     if (in.is_open())
  31.     {
  32.         while (getline(in, line))
  33.         {
  34.             cout << line << " ";
  35.         }
  36.     }
  37.     in.close();
  38.    
  39.     cout << "\nКiлькiсть квадратiв: " << k << endl;
  40.     system("pause");
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment