Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <iostream>
- #include <vector>
- #include <string>
- int main()
- {
- std::fstream file;
- file.open("liczby.txt", std::ios_base::in);
- std::vector<int> v;
- std::string line;
- while (std::getline(file, line))
- {
- v.push_back(std::stoi(line));
- }
- file.close();
- int result{ 0 };
- for (auto const x : v)
- {
- if (x == 1 || x == 3 || x == 9 || x == 27 || x == 81 || x == 243
- || x == 729 || x == 2187 || x == 6561 || x == 19683 || x == 59049)
- {
- ++result;
- }
- }
- file.open("wyniki4.txt", std::ios::out);
- file << "1\n";
- file << result << '\n';
- file.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement