Advertisement
Guest User

Sasha10_13

a guest
Nov 21st, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #include <vector>
  5. #include <ctime>
  6. #include <algorithm>
  7. using namespace std;
  8. int main() {
  9.     setlocale(LC_ALL,  "rus");
  10.     srand(time(NULL));
  11.     ofstream fout;
  12.     int count = 0;
  13.     string p;
  14.     int arr[100];
  15.     fout.open("test.txt");
  16.     for(int i=0;i<100;i++){
  17.         arr[i] = rand();
  18.         fout << i+1 << " элемент: " << arr[i] << endl;
  19.     }
  20.     for(int i=0;i<100;i++){
  21.         p = arr[i];
  22.         if(p.find('5')){
  23.             count++;
  24.         }
  25.     }
  26.     fout << "Чисел содержащих цифру 5: " << count << endl;;
  27.     fout.close();
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement