Advertisement
35657

Untitled

Apr 20th, 2024
407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <Windows.h>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.    
  9.     SetConsoleCP(1251);
  10.     SetConsoleOutputCP(1251);
  11.  
  12.     ofstream fout;
  13.     fout.open("C:/Users/PC/Documents/student.txt", ofstream::app);
  14.  
  15.     if (!fout.is_open()) {
  16.         cout << "Ошибка открытия файла" << endl;
  17.     }
  18.     else {
  19.         string str;
  20.         int count;
  21.         cout << "Сколько студентов необходимо добавить: ";
  22.         cin >> count;
  23.         for (int i = 0; i < count; i++) {
  24.             cout << "Введите фамилию: ";
  25.             cin >> str;
  26.             fout << str << endl;
  27.             cout << "Введите имя: ";
  28.             cin >> str;
  29.             fout << str << endl;
  30.             cout << "Номер зачетной книжки: ";
  31.             cin >> str;
  32.             fout << str << endl;
  33.         }
  34.         fout.close();
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement