Advertisement
LuandaBernardo

FILE (20/01/15)

Jan 22nd, 2015
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.30 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5.  
  6. typedef struct
  7. {
  8.     int codigo, Mouro, Mprata,Mbronze;
  9.     char nome[20];
  10. } pais;
  11.  
  12.  
  13. void CADASTRO (int n, pais CAD[])
  14. {
  15.     int i;
  16.      for  (i=0; i<n; i++)
  17.     {printf ("Codigo:");
  18.     scanf ("%d", &CAD[i].codigo);
  19.     printf ("Nome:");
  20.     fflush (stdin);
  21.     gets (CAD[i].nome);
  22.     printf ("Med. de Ouro, Prata, Bronze");
  23.     scanf ("%d %d %d", &CAD[i].Mouro, &CAD[i].Mprata, &CAD[i].Mbronze);}
  24.  
  25. }
  26.  
  27. main ()
  28. {
  29.     FILE *F;
  30.     int n;
  31.     pais *V;
  32.    
  33.     do
  34.      {
  35.         printf ("Digite o nº de paises");
  36.         scanf ("%d", &n);
  37.     }
  38.     while (n<2 || n>100);
  39.     int op;
  40.    
  41.     printf (" 1 - Cadastrar \n 2 - Consultar \n 3 - Listar Medalhas de outro \n  4 - Salvar em arquivo \n 5 - Carregar informação em Arquivo \n 6 - Sair");
  42.     scanf ("%d", &op);
  43.  
  44. V = (pais*) malloc (n*sizeof(pais));
  45. switch (op)
  46. {
  47. case 1:
  48.     CADASTRO (n, V); break;
  49.     case 2:
  50.        
  51.         break;
  52.         case 3:
  53.             break;
  54.             case 4:
  55.                 break;
  56.                 case 5:
  57.                     break;
  58.                     case 6:
  59.                         return 0;
  60.                         break;
  61.                        
  62.     }
  63.    fclose (F);
  64.    
  65.    return 0;
  66.    
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement