Advertisement
carolct

Untitled

Jan 19th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1. #define MAX 25
  2. #include<stdio.h>
  3. #include<stdlib.h>
  4. #include<conio.h>
  5. #include<string.h>
  6.  
  7.  
  8. void mostrar(void);
  9. void final(void);
  10. void cadastrar(void);
  11. void ordenar(void);
  12. int i;
  13.  
  14. struct aluno
  15. {
  16. char nome[50];
  17. char matricula[20];
  18. char faltas[5];
  19. float Vs1;
  20. float Vs2;
  21. float Vs3;
  22. float Vs4;
  23. float AF;
  24. };
  25.  
  26. struct aluno Taluno[MAX];
  27. int num;
  28.  
  29. int main(void)
  30. {
  31. for (;;)
  32. {
  33. printf("\t\t\t\tCADASTRO DE ALUNOS\n");
  34. printf("1- Mostrar dados do aluno:\n");
  35. printf("2- Alunos que irĂ£o fazer prova final:\n");
  36. printf("3- Cadastrar novos alunos:\n");
  37. printf("4- Medias ordenadas:");
  38. printf("0 - Sair\n");
  39. scanf("%d",&num);
  40. switch(num)
  41. {
  42. case 1: mostrar();
  43. break;
  44. case 2: final();
  45. break;
  46. case 3: cadastrar();
  47. break;
  48. //case 4: ordenar ();
  49. //break;
  50. case 0: exit(0);
  51. default: puts("ERRO: tente outra vez!");
  52. }
  53.  
  54. }
  55. getchar();
  56. }
  57.  
  58. void mostrar (void)
  59. {
  60. int i,n;
  61. float NP1, NP2;
  62. for(i=0; i<n; i++)
  63. {
  64. printf("\n Matricula : %s",Taluno[i].matricula);
  65. printf("\n Nome : %s",Taluno[i].nome);
  66. printf("\n Faltas:%s",Taluno[i].faltas);
  67.  
  68. //printf("\n Vs1 : %.2f", Taluno[i].Vs1);
  69.  
  70. NP1=(Taluno[i].Vs1 + Taluno[i].Vs2)/2;
  71. NP2=(Taluno[i].Vs3 + Taluno[i].Vs4)/2;
  72. printf("\nMedia --> %1.2f",(NP1+NP2)/2);
  73.  
  74. getche();
  75. }}
  76.  
  77.  
  78. void cadastrar (void)
  79. {
  80. int i,n;
  81.  
  82. printf("Quantidade de alunos a serem cadastrados: \n");
  83. scanf("%d",&n);
  84. for(i=0; i<n; i++)
  85. {
  86. fflush(stdin);
  87. printf("Nome do aluno: ");
  88. gets(Taluno[i].nome);
  89. fflush(stdin);
  90. printf("\n\n\nMatricula: ");
  91. gets(Taluno[i].matricula);
  92. fflush(stdin);
  93. printf("Faltas:");
  94. gets(Taluno[i].faltas);
  95. fflush(stdin);
  96. printf("Vs1:");
  97. scanf("%f",&Taluno[i].Vs1);
  98. fflush(stdin);
  99. printf("Vs2:");
  100. scanf("%f", &Taluno[i].Vs2);
  101. fflush(stdin);
  102. printf("Vs3:");
  103. scanf("%f", &Taluno[i].Vs3);
  104. fflush(stdin);
  105. printf("Vs4:");
  106. scanf("%f", &Taluno[i].Vs4);
  107. fflush(stdin);
  108. printf("AF:");
  109. scanf("%f", &Taluno[i].AF);
  110. fflush(stdin);
  111. // printf("%1.2f", (Taluno[i].Vs1 + Taluno[i].Vs2)/2);
  112.  
  113. //Taluno[i].NP1 = Taluno[i].Vs1;
  114. }
  115.  
  116. getche();
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement