Advertisement
LightProgrammer000

Mega Sena [Remasterizado]

Nov 21st, 2018
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.43 KB | None | 0 0
  1. /// Bibliotecas
  2. #include <math.h>
  3. #include <time.h>
  4. #include <conio.h>
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <locale.h>
  8.  
  9. /// Protótipos
  10. char Menu(char cod);
  11. int Gerar_Numeros(int qtd_cartela);
  12.  
  13. /// Programa
  14. int main()
  15. {
  16.     // Sistema
  17.     setlocale(LC_ALL, "");
  18.  
  19.     char cod = 's';
  20.     int qtd_cartela;
  21.  
  22.     do
  23.     {
  24.         while( cod != 'n' || cod != 'n' )
  25.         {
  26.             // Relatório
  27.             system("cls & color E");
  28.             printf("\n ============================\n");
  29.             system("echo  - Usuario: %username%");
  30.             system("echo  - Computador: %computername%");
  31.             system("echo  - Data: %date:/=-%");
  32.             system("echo  - Hora: %time:~0,-3%");
  33.             printf(" ============================\n\n\n");
  34.  
  35.             printf(" ==========================\n");
  36.             printf("     JOGO DA MEGA SENA     \n");
  37.             printf(" ==========================\n");
  38.  
  39.             // Entrada de Dados
  40.             printf("\n * Quantos Cartelas de Jogos Deseja Gerar ?");
  41.             printf("\n - Opc: ");
  42.             scanf("%d", &qtd_cartela );
  43.  
  44.             // Chamada de Função
  45.             Gerar_Numeros(qtd_cartela);
  46.  
  47.             //int Gerando_Cartelas(qtd_cartela);
  48.             cod = Menu(cod);
  49.         }
  50.  
  51.     } while ( qtd_cartela < 0 );
  52.  
  53.     return(0);
  54. }
  55.  
  56. //////////////////// FUNÇÕES ////////////////////
  57.  
  58. // Menu Interativo
  59. char Menu(char cod)
  60. {
  61.     system("cls & color C");
  62.  
  63.     printf("\n - Deseja Continuar ? ");
  64.     printf("\n [s] - Sim");
  65.     printf("\n [n] - Nao");
  66.     printf("\n\n - Opc: ");
  67.  
  68.     // Atribuição
  69.     cod = getche();
  70.  
  71.     return(cod);
  72. }
  73.  
  74. int Gerar_Numeros(int qtd_cartela)
  75. {
  76.     // Variáveis
  77.     int a, b;
  78.     int aleatorios;
  79.  
  80.     // Controlador de Numeros Aleatórios
  81.     srand( (unsigned) time(NULL) );
  82.  
  83.     for( a = 1 ; a <= qtd_cartela ; a ++ )
  84.     {
  85.         system("cls & color B");
  86.         printf("\n =================\n");
  87.         printf("     CARTELA %d     \n", a );
  88.         printf(" =================\n\n");
  89.  
  90.         // Estrutura de Repetição
  91.         for( b = 1 ; b <= 6 ; b ++ )
  92.         {
  93.              // Comandos: Geracao de Numeros de 1 a 60
  94.             aleatorios = rand();
  95.             aleatorios = ( aleatorios % 60 ) + 1;
  96.  
  97.             printf(" - Número [%d] : %d \n", b , aleatorios );
  98.         }
  99.  
  100.         printf("\n\n");
  101.         system("pause");
  102.     }
  103.  
  104.     return(0);
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement