Guest User

Untitled

a guest
Jun 25th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include "cstdlib"
  4. #include <string.h>
  5. #define MAX 30
  6. struct STUDENT
  7. {
  8. char fio[15];
  9. char oc[7];
  10. };
  11. struct EL_TAB
  12. {
  13. char fio[15];
  14. int oc[5];
  15. float srball;
  16. };
  17. void PechTab (EL_TAB *tab, int n);
  18. void Stud(EL_TAB *tab, int n);
  19. void otl(EL_TAB *tab, int n);
  20. void main()
  21. {
  22. FILE *f;
  23. STUDENT tz;
  24. EL_TAB tab[MAX];
  25. int n;
  26. int i;
  27. float s;
  28. if ((f=fopen("st.txt","r"))==NULL)
  29. {
  30. puts("Fail st.txt ne naiden");
  31. return;
  32. }
  33. n=0;
  34. while (fgets((char *)&tz, sizeof(struct STUDENT), f)!=NULL)
  35. {
  36. for(i=0, s=0; i<5; i++)
  37. {
  38. int ocenka=tz.oc[i]-'0';
  39. tab[n].oc[i]=ocenka;
  40. s+=ocenka;
  41. }
  42. tz.fio[14]='\0';
  43. strcpy(tab[n].fio,tz.fio);
  44. tab[n++].srball=s/5;
  45. }
  46. fclose(f);
  47. char nom;
  48. do
  49. {
  50. system("cls");
  51. puts("---------------------------------");
  52. puts("viberite nomer pynkta meny:");
  53. puts("1 - srednie bally studentov");
  54. puts("2- infa o zadannom studente");
  55. puts("3-infa ob otlichnikax");
  56. puts("4- vyxod");
  57. nom =getche();
  58. switch(nom)
  59. {
  60. case'1': PechTab(tab,n); break;
  61. case'2': Stud(tab,n); break;
  62. case'3': otl(tab, n); break;
  63. case'4': break;
  64. default: puts("\n Nygno vvesti nomer ot 1 do 3");
  65. }
  66. if(nom!='4')
  67. {
  68. puts("\n Dlya prodolgenia nagmite lybui klavishu");
  69. getch();
  70. }
  71. }
  72. while(nom!='4');
  73. }
  74. void PechTab(EL_TAB *tab, int n)
  75. {
  76. int j;
  77. puts ("\n Family I.O. Sr. ball");
  78. puts("------------------------------");
  79. for(j=0; j<n; j++)
  80. {
  81. printf("%s %.1f\n", tab[j].fio, tab[j].srball);
  82. }
  83. }
  84. void Stud(EL_TAB *tab, int n)
  85. {
  86. int a, b=0,i;
  87. char poisk[15];
  88. printf("\n Vvedite family\n");
  89. gets(poisk);
  90. a=strlen(poisk);
  91. for(i=0; i<n; i++)
  92. {
  93. if(strncmp(poisk, tab[i].fio, a)==0)
  94. {
  95. b=1;
  96. puts("Family I.O. srball");
  97. printf("%s %.1f\n", tab[i].fio, tab[i].srball);
  98. break;
  99. }
  100. }
  101. if(b!=1)
  102. {
  103. puts("Takogo cheloveka v spiske net!!!");
  104. }
  105. }
  106. void otl(EL_TAB *tab, int n)
  107. {
  108. int i, b=0;
  109. puts("spisok otl");
  110. for(i=0; i<n; i++)
  111. {
  112. if(tab[i].srball==5)
  113. {b=1;
  114. printf("%s %.1f\n", tab[i].fio, tab[i].srball);
  115. break;
  116. }
  117.  
  118. }
  119. if(b!=1)
  120. puts("otl net");
  121. }
Add Comment
Please, Sign In to add comment