Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- #include "cstdlib"
- #include <string.h>
- #define MAX 30
- struct STUDENT
- {
- char fio[15];
- char oc[7];
- };
- struct EL_TAB
- {
- char fio[15];
- int oc[5];
- float srball;
- };
- void PechTab (EL_TAB *tab, int n);
- void Stud(EL_TAB *tab, int n);
- void otl(EL_TAB *tab, int n);
- void main()
- {
- FILE *f;
- STUDENT tz;
- EL_TAB tab[MAX];
- int n;
- int i;
- float s;
- if ((f=fopen("st.txt","r"))==NULL)
- {
- puts("Fail st.txt ne naiden");
- return;
- }
- n=0;
- while (fgets((char *)&tz, sizeof(struct STUDENT), f)!=NULL)
- {
- for(i=0, s=0; i<5; i++)
- {
- int ocenka=tz.oc[i]-'0';
- tab[n].oc[i]=ocenka;
- s+=ocenka;
- }
- tz.fio[14]='\0';
- strcpy(tab[n].fio,tz.fio);
- tab[n++].srball=s/5;
- }
- fclose(f);
- char nom;
- do
- {
- system("cls");
- puts("---------------------------------");
- puts("viberite nomer pynkta meny:");
- puts("1 - srednie bally studentov");
- puts("2- infa o zadannom studente");
- puts("3-infa ob otlichnikax");
- puts("4- vyxod");
- nom =getche();
- switch(nom)
- {
- case'1': PechTab(tab,n); break;
- case'2': Stud(tab,n); break;
- case'3': otl(tab, n); break;
- case'4': break;
- default: puts("\n Nygno vvesti nomer ot 1 do 3");
- }
- if(nom!='4')
- {
- puts("\n Dlya prodolgenia nagmite lybui klavishu");
- getch();
- }
- }
- while(nom!='4');
- }
- void PechTab(EL_TAB *tab, int n)
- {
- int j;
- puts ("\n Family I.O. Sr. ball");
- puts("------------------------------");
- for(j=0; j<n; j++)
- {
- printf("%s %.1f\n", tab[j].fio, tab[j].srball);
- }
- }
- void Stud(EL_TAB *tab, int n)
- {
- int a, b=0,i;
- char poisk[15];
- printf("\n Vvedite family\n");
- gets(poisk);
- a=strlen(poisk);
- for(i=0; i<n; i++)
- {
- if(strncmp(poisk, tab[i].fio, a)==0)
- {
- b=1;
- puts("Family I.O. srball");
- printf("%s %.1f\n", tab[i].fio, tab[i].srball);
- break;
- }
- }
- if(b!=1)
- {
- puts("Takogo cheloveka v spiske net!!!");
- }
- }
- void otl(EL_TAB *tab, int n)
- {
- int i, b=0;
- puts("spisok otl");
- for(i=0; i<n; i++)
- {
- if(tab[i].srball==5)
- {b=1;
- printf("%s %.1f\n", tab[i].fio, tab[i].srball);
- break;
- }
- }
- if(b!=1)
- puts("otl net");
- }
Add Comment
Please, Sign In to add comment