Advertisement
STANAANDREY

pb4 11/11/2019

Nov 11th, 2019
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. using namespace std;
  6.  
  7. typedef struct
  8. {
  9.     char nume[100];
  10.     float med, val;
  11. } STUD;
  12.  
  13. int main()
  14. {
  15.     STUD s[100];
  16.     int n = 0, x;
  17.  
  18.     do
  19.     {
  20.         cout << "1 - ADAUGA STUDENT" << endl;
  21.         cout << "2 - listare studenti" << endl;
  22.         cout << "3 - cautare student" << endl;
  23.         cout << "4 - exit:" << endl;
  24.         cout << "alege o optiune:" << endl;
  25.         cin >> x;
  26.         getchar();
  27.  
  28.         switch (x)
  29.         {
  30.         case 1:
  31.  
  32.             STUD st;
  33.             cout << "introdu datele (nume-medie-valoare bursa):" << endl;
  34.             gets(st.nume);
  35.             cin >> st.med >> st.val;
  36.             s[n++] = st;
  37.             break;
  38.  
  39.         case 2:
  40.  
  41.             cout << "Lista studenti:" << endl;
  42.             for (int i = 0; i < n; i++)
  43.                 cout << s[i].nume << ' ' << s[i].med << ' ' << s[i].val << endl;
  44.             break;
  45.  
  46.         case 3:
  47.  
  48.             cout << "nume student:" << endl;
  49.             char nume[100];
  50.             gets(nume);
  51.             for (int i = 0, f = i; i < n && !f; i++)
  52.                 if (!strcmp(s[i].nume, nume))
  53.                 {
  54.                     cout << s[i].med << ' ' << s[i].val << endl;
  55.                     f = 1;
  56.                 }
  57.             break;
  58.  
  59.         case 4:
  60.             break;
  61.         default:
  62.             cout << "optiune inexistenta!" << endl;
  63.         }
  64.  
  65.     }
  66.     while (x != 4);
  67.  
  68.     return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement