Advertisement
35657

Untitled

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