daily pastebin goal
79%
SHARE
TWEET

Untitled

a guest Oct 22nd, 2018 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void main() {
  2.     const int N = 1;
  3.     string array[20];
  4.     string checkFN;
  5.     bool flag = false;
  6.     static Person *mas[N];
  7.     string StrName, StrEgn, StrSpec, StrFn;
  8.     int Pol;
  9.     fstream myfile;
  10.  
  11.     setlocale(LC_ALL, "Bulgarian");
  12.     string a, b, d, e;
  13.     int c;
  14.     myfile.open("myfile.txt", ios::out | ios::app);
  15.     for (int i = 0; i < N; i++) {
  16.         cout << "Въведете име: ";
  17.         getline(cin, StrName);
  18.  
  19.         do {
  20.             cout << "Въведете ЕГН(10 цифри): ";
  21.             getline(cin, StrEgn);
  22.         } while (StrEgn.length() != 10);
  23.  
  24.         do {
  25.             cout << "Въведете пол(1-Мъж/2-Жена) :";
  26.             cin >> Pol;
  27.         } while (Pol < 1 || Pol>2);
  28.  
  29.         cout << "Въведете специалност:";
  30.         cin.ignore();
  31.         getline(cin, StrSpec);
  32.  
  33.         do {
  34.             cout << "Въведете факултетен номер(8 цифри):";
  35.             getline(cin, StrFn);
  36.         } while (StrFn.length() != 8);
  37.  
  38.         sex val = static_cast<sex>(Pol);
  39.         mas[N] = new Student(StrName, StrEgn, val, StrSpec, StrFn);
  40.         cout << endl;
  41.         cout << endl;
  42.         myfile << StrName << " " << StrEgn << " " << Pol << " " << StrSpec << " " << StrFn << " " << endl;
  43.     }
  44.     myfile.close();
  45.     myfile.open("myfile.txt", ios::in);
  46.     int counter = 0;
  47.     int counter1 = 0;
  48.     while (myfile >> a >> b >> c >> d >> e) {
  49.         cout << "Име: " << a << endl << "ЕГН: " << b << endl << "Пол: ";
  50.         if (c == 1) { cout << "Мъж"; }
  51.         else { cout << "Жена"; }
  52.         cout << endl << "Специалност: " << d << endl << "Факултетен номер: " << e << endl;
  53.         array[counter] = e;
  54.         counter++;
  55.     }
  56.     cout << endl << "Vuvedete FN za proverka na student";
  57.     getline(cin, checkFN);
  58.     for (int i = 0; i < counter; i++) {
  59.         if (checkFN == array[i]) {
  60.             flag = true;
  61.         }
  62.     }
  63.     if (flag == true) cout << "\n Ima takuv student.\n";
  64.     else cout << "\n Nqma takuv student\n";
  65.     system("pause");
  66. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top