Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void main() {
- const int N = 1;
- string array[20];
- string checkFN;
- bool flag = false;
- static Person *mas[N];
- string StrName, StrEgn, StrSpec, StrFn;
- int Pol;
- fstream myfile;
- setlocale(LC_ALL, "Bulgarian");
- string a, b, d, e;
- int c;
- myfile.open("myfile.txt", ios::out | ios::app);
- for (int i = 0; i < N; i++) {
- cout << "Въведете име: ";
- getline(cin, StrName);
- do {
- cout << "Въведете ЕГН(10 цифри): ";
- getline(cin, StrEgn);
- } while (StrEgn.length() != 10);
- do {
- cout << "Въведете пол(1-Мъж/2-Жена) :";
- cin >> Pol;
- } while (Pol < 1 || Pol>2);
- cout << "Въведете специалност:";
- cin.ignore();
- getline(cin, StrSpec);
- do {
- cout << "Въведете факултетен номер(8 цифри):";
- getline(cin, StrFn);
- } while (StrFn.length() != 8);
- sex val = static_cast<sex>(Pol);
- mas[N] = new Student(StrName, StrEgn, val, StrSpec, StrFn);
- cout << endl;
- cout << endl;
- myfile << StrName << " " << StrEgn << " " << Pol << " " << StrSpec << " " << StrFn << " " << endl;
- }
- myfile.close();
- myfile.open("myfile.txt", ios::in);
- int counter = 0;
- int counter1 = 0;
- while (myfile >> a >> b >> c >> d >> e) {
- cout << "Име: " << a << endl << "ЕГН: " << b << endl << "Пол: ";
- if (c == 1) { cout << "Мъж"; }
- else { cout << "Жена"; }
- cout << endl << "Специалност: " << d << endl << "Факултетен номер: " << e << endl;
- array[counter] = e;
- counter++;
- }
- cout << endl << "Vuvedete FN za proverka na student";
- getline(cin, checkFN);
- for (int i = 0; i < counter; i++) {
- if (checkFN == array[i]) {
- flag = true;
- }
- }
- if (flag == true) cout << "\n Ima takuv student.\n";
- else cout << "\n Nqma takuv student\n";
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement