Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- using namespace std;
- int main() {
- int a, b = 2;
- setlocale(LC_ALL, "ru");
- string path = "file.txt";
- ofstream fout;
- fout.open(path);
- if (!fout.is_open()) {
- cout << "Ошибка открытия файла" << endl;
- }
- else {
- for (int i = 0; i < 10; i++) {
- cout << "Введите число" << endl;
- cin >> a;
- fout << a;
- fout << "\n";
- }
- string str;
- ifstream fin;
- fin.open(path);
- while (!fin.eof()) {
- getline(fin, str);
- cout << str << endl;
- if (str[str.length() - 1] == b) {
- int count = 0;
- count++;
- cout << "Count = " << count << endl;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement