Advertisement
gtw7375

atividade sidney

Oct 15th, 2014
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.90 KB | None | 0 0
  1. struct colegio
  2.             {
  3.                 int matricula, nota1, nota2, nota3;
  4.                 char nome[15], curso[20];
  5.                                
  6.             };
  7.  
  8. int cadastro(struct colegio vet[]){
  9.  
  10.     int i; 
  11.  
  12.                 for(i=0; i<2; i++){
  13.                
  14.                 printf("Informe o nΒΊ de matricula desejada:\n");       scanf("%d", &vet[i].matricula);
  15.                 printf("Informe seu nome:\n");                          scanf("%s", &vet[i].nome);
  16.                 printf("Informe seu curso:\n");                         scanf("%s", &vet[i].curso);
  17.                 printf("Informe your first nota:\n");                   scanf("%d", &vet[i].nota1);
  18.                 printf("Informe your second nota:\n");                  scanf("%d", &vet[i].nota2);
  19.                 printf("Informe your third nota:\n");                   scanf("%d", &vet[i].nota3);                            
  20.                 }
  21. }
  22.  
  23.  
  24. int consulta(struct colegio vet[]){
  25.    
  26.     int i, con;
  27.    
  28.             printf("Informe a matricula que deseja consultar:");        scanf("%d", &con);
  29.            
  30.                 for(i=0; i<2; i++){
  31.                 if(con == vet[i].matricula){
  32.                    
  33.                        
  34.                             printf("%s\n", vet[i].nome);
  35.                             printf("%s\n", vet[i].curso);
  36.                             printf("%d\n", vet[i].nota1);
  37.                             printf("%d\n", vet[i].nota2);
  38.                             printf("%d\n", vet[i].nota3);
  39.                 } else {
  40.                     printf("Matricula invalida!");
  41.                 }
  42.             }
  43.            
  44. }
  45.  
  46. int theBest(struct colegio vet[]){
  47.    
  48.     int i, maior=0;
  49.    
  50.         for(i=0; i<2; i++){
  51.            
  52.         //  if(maior<vet[i].nota1)
  53.        
  54.         }
  55. }
  56.  
  57. int media(struct colegio vet[]){
  58.    
  59.     int i, nota;
  60.    
  61.         for(i=0; i<2; i++){
  62.        
  63.         nota = vet[i].nota1 + vet[i].nota2 + vet[i].nota3;
  64.        
  65.        
  66.                 printf("\n%d\n", vet[i].matricula);
  67.                 printf("%s\n",   vet[i].nome);
  68.                 printf("%s\n",   vet[i].curso);
  69.                 printf("%d",     nota);
  70.         }
  71.    
  72. }
  73.  
  74.  
  75.  
  76. main(){
  77.    
  78.     int opcao, i, veto[2];
  79.    
  80.        
  81.             struct colegio
  82.             {
  83.                 int matricula, nota1, nota2, nota3;
  84.                 char nome[15], curso[20];
  85.                                
  86.             }vetor[2];
  87.        
  88.    
  89.    
  90.    
  91.    
  92.    
  93.    
  94.         printf("############### - Colegio Nossa Senhora dos Pecados - ############### \n");
  95.         printf("1 - Cadastrar \n");
  96.         printf("2 - Exibir todos os alunos \n");
  97.         printf("3 - Consulta \n");
  98.         printf("4 - Best student \n");
  99.         printf("5 - Media dos alunos \n");
  100.         scanf("%d", &opcao);
  101.        
  102.         while(opcao != 6){
  103.            
  104.             switch(opcao){
  105.                
  106.                 case 1:
  107.                         cadastro(vetor);
  108.                    
  109.                             break;
  110.                 case 2:
  111.                    
  112.                         for(i=0; i<2; i++){
  113.                             printf("\n%d\n", vetor[i].matricula);
  114.                             printf("%s\n", vetor[i].nome);
  115.                             printf("%s\n", vetor[i].curso);
  116.                             printf("%d\n", vetor[i].nota1);
  117.                             printf("%d\n", vetor[i].nota2);
  118.                             printf("%d\n", vetor[i].nota3);
  119.                         }
  120.                    
  121.                             break;
  122.                 case 3:
  123.                    
  124.                         consulta(vetor);
  125.                         break;
  126.                
  127.                 case 4:
  128.                    
  129.                     theBest(vetor);
  130.                         break;
  131.                        
  132.                 case 5:
  133.                        
  134.                         media(vetor);
  135.                         break;
  136.                
  137.             }
  138.            
  139.                    
  140.                
  141.                         printf("\n1 - Cadastrar\n");
  142.                         printf("2 - Exibir todos os alunos\n");
  143.                         printf("3 - Consulta\n");
  144.                         printf("4 - Best student\n");
  145.                         printf("5 - Media dos alunos\n");
  146.                         scanf("%d", &opcao);
  147.            
  148.            
  149.            
  150.             }
  151.            
  152.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement