Advertisement
Guest User

Untitled

a guest
May 24th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include <fstream>
  2. #include <iostream>
  3. #include <vector>
  4. #include <string>
  5.  
  6. int main()
  7. {
  8.     std::fstream file;
  9.     file.open("liczby.txt", std::ios_base::in);
  10.     std::vector<int> v;
  11.     std::string line;
  12.     while (std::getline(file, line))
  13.     {
  14.         v.push_back(std::stoi(line));
  15.     }
  16.     file.close();
  17.  
  18.     int result{ 0 };
  19.     for (auto const x : v)
  20.     {
  21.         if (x == 1 || x == 3 || x == 9 || x == 27 || x == 81 || x == 243
  22.             || x == 729 || x == 2187 || x == 6561 || x == 19683 || x == 59049)
  23.         {
  24.             ++result;
  25.         }
  26.     }
  27.  
  28.     file.open("wyniki4.txt", std::ios::out);
  29.     file << "1\n";
  30.     file << result << '\n';
  31.     file.close();
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement