Guest User

Untitled

a guest
Jan 23rd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. # define Linhas 10
  5. # define Colunas 2
  6.  
  7. typedef struct
  8. {
  9. int ra;
  10. char nome[50];
  11. }tAlunos;
  12.  
  13. void lerDados(tAlunos *v[Linhas][Colunas]);
  14.  
  15. int main(int argc, char *argv[])
  16. {
  17. tAlunos alunos[Linhas][Colunas];
  18. int opcao;
  19.  
  20. printf("\n * Inserir alunos e mante-los ordenados pelo RA *\n");
  21. printf("_______________________________________________________________________________\n\n");
  22. printf(" Escolha a opcao:\n\n\n");
  23. printf(" Opcao 1: Inserir um novo registro.\n\n");
  24. printf(" Opcao 2: Listar todos os registros da tabela.\n\n");
  25. printf(" Opcao 3: Encerrar a execucao.\n");
  26. printf("_______________________________________________________________________________\n\n");
  27.  
  28. do
  29. {
  30. printf(" Digite a opcao [ 1, 2 ou 3 ]: ");
  31. scanf("%d", &opcao);
  32. printf("\n");
  33.  
  34. switch (opcao)
  35. {
  36. case 1:
  37. lerDados (&alunos);
  38. break;
  39. }
  40. }
  41. while (opcao < 3);
  42.  
  43.  
  44. system("PAUSE");
  45. return 0;
  46. }
  47.  
  48. void lerDados (tAlunos *v[Linhas][Colunas])
  49. {
  50. int i, j;
  51.  
  52. for (i = 0; i < Linhas; i++)
  53. {
  54. printf(" Digite os nomes da %do. aluno\n\n", i+1);
  55. fflush(stdin);
  56. gets(v[i][j]->nome);
  57. printf("\n");
  58. for (j = 0; j < Colunas; j++)
  59. {
  60. printf(" O ra do %do. aluno = ", i+1);
  61. scanf("%d", &v[i][j]->ra);
  62. printf("\n");
  63. }
  64. }
  65. }
Add Comment
Please, Sign In to add comment