Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <stdio.h>
- using namespace std;
- #define NMAX 10000
- #define LENMAX 25
- typedef struct
- {
- char name[LENMAX];
- float med, val;
- } STUD;
- STUD arr_s[NMAX];
- int nr_stud;
- void add_stud()
- {
- STUD temp;
- cin.get();
- cin.getline(temp.name, LENMAX);
- cin >> temp.med >> temp.val;
- arr_s[nr_stud++] = temp;
- }
- void display()
- {
- if (!nr_stud)
- puts("Lista e goala");
- for (int i = 0; i < nr_stud; i++)
- puts(arr_s[i].name);
- }
- void search_stud()
- {
- cin.get();
- char name[LENMAX];
- cin.getline(name, LENMAX);
- int f = 0;
- for (int i = 0; i < nr_stud && !f; i++)
- if (!strcmp(arr_s[i].name, name))
- {
- f = 1;
- cout << arr_s[i].name << ' ' << arr_s[i].med << ' ' << arr_s[i].val << endl;
- }
- if (!f)
- puts("Student inexistent!");
- }
- void menu()
- {
- puts("1-adauga student;");
- puts("2-afiseaza studentii;");
- puts("3-afiseza informatii despre un student");
- puts("4-Exit");
- int op;
- do
- {
- cin >> op;
- switch (op)
- {
- case 1:
- add_stud();
- break;
- case 2:
- display();
- break;
- case 3:
- search_stud();
- break;
- case 4:
- puts("Se inchide!");
- break;//*/
- default:
- puts("Optiune inexistenta!");//*/
- }
- }
- while (op != 4);
- }
- int main()
- {
- menu();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement