Advertisement
Guest User

Untitled

a guest
Apr 9th, 2020
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 12.59 KB | None | 0 0
  1. #include <locale.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>  //biblioteca para comparar strings.
  5. #include <time.h>    // biblioteca para uso de funcional de srand.
  6. #include <windows.h>
  7. #define senha_ADM 4321
  8. #define loguin_ADM "stonks"
  9.  
  10. #define setlocale (LC_ALL, "portuguese");
  11. #define MENUPRINCIPAL "              %c BEM VINDO A RIFA BATUTA STONKS\n\n\n\t       ============================\n\t       \n\t       \t\tSELECIONE:        \n\t       \n\t       ============================  \n \t       _________________\n\n\t       |1-CADASTRO DE RIFA\n\t       |\n \t       |2-LOGUIN ADM\n\t       | \t\t\n \t       |0-SAIR*\n\t       _________________\n\n Escolha sua acao:"
  12. #define CONTINUAR "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nAPERTE ENTER PARA CONTINUAR. "
  13.  
  14. void gotoxy(int x, int y) {  //void para utilizar o gotoxy
  15.  
  16.     COORD coord;
  17.     coord.X = x;
  18.     coord.Y = y;
  19.     SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
  20. }
  21.  
  22.  
  23. void telasorteio(void) {  //void com a tela de sorteio
  24. int i = 0;
  25.     for(i=0; i < 41; i++ ){
  26.         printf("%c", 220);
  27.     }
  28.     printf("\n");    
  29.  
  30.     printf("%c",219 );
  31.     printf("\tOS NUMEROS DOS GANHADORES SAO...%c\n",219);
  32.     printf("%c\t\t\t\t        %c\n",219, 219);
  33.     printf("%c", 219);
  34.    
  35.     for(i=0; i < 39; i++ ){
  36.         printf("%c", 220);
  37.     }    
  38.     printf("%c", 219);
  39.    
  40. }
  41.  
  42. void sorteio(void) {  //sorteio de um numero aleatorio
  43.  
  44.     srand(time(NULL));
  45.     telasorteio();
  46.     // sorteia o nro
  47.     gotoxy(15, 2);    
  48.     printf("%d        %d       ", rand()%69 + 1  , rand ()%69+1);
  49.    
  50.     printf("\n\n\n\n\n"CONTINUAR);
  51. }
  52.  
  53. void telaloguin_ADM(void) {  // tela de loguin do adm
  54.  
  55.     int senhaADM2;
  56.     char loguin_ADM2[10];
  57.     char resp_ADM;
  58.     setlocale (LC_ALL, "portuguese");
  59.     system("cls");
  60.  
  61.     do {  //repeticao para caso de erro no loguin
  62.         resp_ADM = 'n';
  63.         system("cls");
  64.         molduratela();  //chamando a moldura da tela
  65.         resp_ADM = 'n';
  66.         gotoxy(1, 2);
  67.         printf(" =========================** AREA DO ADMINISTRADOR **========================\n\n");
  68.         gotoxy(4, 4);
  69.         printf("Nome de usuario ADM:");
  70.         fflush(stdin);
  71.         scanf("%s", &loguin_ADM2);
  72.         gotoxy(4, 6);
  73.         printf("Sua senha numerica:");
  74.         fflush(stdin);
  75.         scanf("%i", &senhaADM2);
  76.  
  77.         if (strcmp(loguin_ADM2, loguin_ADM) != 0) {  // comparando strings com strcmp, resto 0 = strings iguais, resto !=(diferente) 0 strings diferentes.
  78.  
  79.             system("cls");
  80.             gotoxy(10,2);
  81.             printf("================** SOMENTE ADMINISTRADORES!! **===================");
  82.             gotoxy(13,6);
  83.             printf("Sua credencial esta errada!\n\n");
  84.             gotoxy(13,10);
  85.             printf("Aperte S para tentar novamente");
  86.             fflush(stdin);
  87.             resp_ADM = getch();
  88.             system("cls");
  89.             telaloguin_ADM();  //chamando tela de loguin do adm novamente em caso de erro da credencial.
  90.         }
  91.  
  92.         if (senhaADM2 == senha_ADM) {  //comparado senhas / senha_ADM prefinida
  93.  
  94.             gotoxy(4, 8);
  95.             printf("Loguin feito com sucesso!");
  96.             sleep(3);
  97.             system("cls");
  98.             menu_ADM();  // chamando menu de adm.
  99.  
  100.         } else if (senhaADM2 != senha_ADM) {  //comparando senhas para caso houver erro.
  101.  
  102.             system("cls");
  103.             gotoxy(10,2);
  104.             printf("================** SOMENTE ADMINISTRADORES!! **===================");
  105.             gotoxy(13,6);
  106.             printf("Suas senhas nao combinam!\n\n");
  107.             gotoxy(13,10);
  108.             printf("Aperte S para tentar novamente!");
  109.             fflush(stdin);
  110.             resp_ADM = getch();
  111.             system("cls");
  112.         }
  113.  
  114.     } while ((resp_ADM == 'S') || (resp_ADM == 's'));  //repeticao de loop
  115. }
  116.  
  117. void menu_ADM(void) {  //void ta dela de menu do adm
  118.  
  119.     char opADM;
  120.     setlocale (LC_ALL, "portuguese");
  121.    
  122.     system("cls");
  123.     molduratela();
  124.     gotoxy(12,8);
  125.     printf("___________________");
  126.     gotoxy(12,3);
  127.     printf("___________________");
  128.     gotoxy(7,2);
  129.     printf(" ===================** AREA DO ADMINISTRADOR **===================\n\n");
  130.     gotoxy(12,5);
  131.     printf("1 - Sorteio.");
  132.     gotoxy(12,7);
  133.     printf("2 - Sair.");
  134.     gotoxy(12,10);
  135.     printf("Qual sua escolha:");
  136.     fflush(stdin);
  137.     opADM = getch();
  138.  
  139.     if (opADM == '1') {
  140.         system("cls");
  141.         sorteio();
  142.  
  143.     } else if (opADM == '2') {
  144.         system("cls");
  145.         main();
  146.     }
  147. }
  148.  
  149. void telarifa (void) {
  150.     system("cls");
  151.     char op2;
  152.     int cont, cont25;
  153.     cont = 1;
  154.    
  155.     while (cont < 51){
  156.        if (cont >=1  &&  cont<=9){
  157.        
  158.         printf ("0");
  159.            
  160.   }
  161.        
  162.         printf("%i ", cont);
  163.    
  164.     if (cont %10 == 0){
  165.         printf("\n");
  166.            
  167.         }
  168.          
  169.        
  170.        
  171.         cont = cont + 1;
  172.        
  173.        
  174.     }
  175.   printf ("APERTE 0 PARA VOLTAR OU ENTER PARA SAIR");
  176.   fflush(stdin);
  177.   op2=getch();
  178.  
  179.   if (op2 == '0'){
  180.  
  181.      system("cls");
  182.      menu2();
  183.    
  184.      
  185. }
  186.  
  187. }
  188. void menu2(void) {  //void para o menu2 pós cadastro/loguin
  189.  
  190.     char op;
  191.     setlocale (LC_ALL, "portuguese");
  192.    
  193.     system("cls");
  194.     gotoxy (15,4);
  195.     printf("** BEM VINDO! **\n\n");
  196.     gotoxy(12,6);
  197.     printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", 223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223);
  198.     gotoxy (12,6);
  199.     printf("%c", 219);
  200.     gotoxy (12,7);
  201.     printf("%c", 219);
  202.     gotoxy (12,8);
  203.     printf("%c", 219);
  204.     gotoxy (12,9);
  205.     printf("%c", 219);
  206.     gotoxy (12,10);
  207.     printf("%c", 219);
  208.     gotoxy (12,11);
  209.     printf("%c", 219);
  210.     gotoxy (12,12);
  211.     printf("%c", 219);
  212.     gotoxy (12,13);
  213.     printf("%c", 219);
  214.     gotoxy (12,14);
  215.     printf("%c", 219);
  216.     gotoxy (12,15);
  217.     printf("%c", 219);
  218.     gotoxy (12,16);
  219.     printf("%c", 219);
  220.     gotoxy (12,17);
  221.     printf("%c", 219);
  222.     gotoxy (12,18);
  223.     printf("%c", 219);
  224.     gotoxy(12,19);
  225.     printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", 223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223);
  226.      gotoxy (45,6);
  227.     printf("%c", 219);
  228.     gotoxy(45,7);    
  229.     printf("%c", 219);
  230.     gotoxy (45,8);
  231.     printf("%c", 219);
  232.     gotoxy (45,9);
  233.     printf("%c", 219);
  234.     gotoxy (45,10);
  235.     printf("%c", 219);
  236.     gotoxy (45,11);
  237.     printf("%c", 219);
  238.     gotoxy (45,12);
  239.     printf("%c", 219);
  240.     gotoxy (45,13);
  241.     printf("%c", 219);
  242.     gotoxy (45,14);
  243.     printf("%c", 219);
  244.     gotoxy (45,15);
  245.     printf("%c", 219);
  246.     gotoxy (45,16);
  247.     printf("%c", 219);
  248.     gotoxy (45,17);
  249.     printf("%c", 219);
  250.     gotoxy (45,18);
  251.     printf("%c", 219);
  252.     gotoxy (21, 9);
  253.     printf("\t1 = TelaRifa.");
  254.     gotoxy(21,13);
  255.     printf("\t2 = Saida.");
  256.     gotoxy(16,17);
  257.     printf("Pressione para prosseguir:");
  258.     fflush(stdin);
  259.     op = getch();
  260.  
  261.     if (op == '1') {
  262.         system("cls");
  263.         printf("\n\n\n\n\n\n\n\n\n\n\n");
  264.         telarifa();
  265.    
  266.     } else if (op == '2') {
  267.         system("cls");
  268.         main();
  269.     }
  270. }
  271.  
  272. void molduratela(void) {  //void para moldura das telas
  273.  
  274.     int i, j, l, k;       //variaveis para receber o código ASCII
  275.     setlocale (LC_ALL, "portuguese");
  276.    
  277.    
  278.     for (i = 0; i < 79; i++) {
  279.         printf("%c", 220);
  280.     }
  281.     printf("\n");
  282.  
  283.     for (j = 0; j < 9; j++) {
  284.         printf("%c", 219);
  285.         for (i = 0; i < 77; i++) {
  286.             printf(" ");
  287.         }
  288.         printf("%c\n", 219);
  289.     }
  290.  
  291.     printf("%c", 219);
  292.     for (i = 0; i < 26; i++) {
  293.         printf(" ");
  294.     }
  295.     printf("                         ");
  296.     for (i = 0; i < 26; i++) {
  297.         printf(" ");
  298.     }
  299.     printf("%c\n", 219);
  300.  
  301.     for (j = 0; j < 9; j++) {
  302.         printf("%c", 219);
  303.         for (i = 0; i < 77; i++) {
  304.             printf(" ");
  305.         }
  306.         printf("%c\n", 219);
  307.     }
  308.     printf("%c", 219);
  309.     for (i = 0; i < 77; i++) {
  310.         printf("%c", 220);
  311.     }
  312.     printf("%c", 219);
  313.     printf("\n");
  314. }
  315.  
  316. void telacadastro() {  //void para tela de cadastro
  317.  
  318.     int senhac1, senhac2, senhal;
  319.     char loguin, resp;
  320.     setlocale (LC_ALL, "portuguese");
  321.     molduratela();
  322.     gotoxy(18, 5);
  323.  
  324.     do {
  325.         system("cls");
  326.     molduratela();
  327.     resp = 'n';
  328.     gotoxy(4,3);
  329.     printf("\t   =======================** CADASTRO **=======================\n\n");
  330.     gotoxy(14,5);
  331.     printf("____________________________________________________");
  332.     gotoxy(10,7);
  333.     printf("    Escolha seu nome de usuario:");
  334.     fflush(stdin);
  335.     scanf("%c", &loguin);
  336.     gotoxy(14,9);
  337.     printf("Escolha sua senha (somente com numeros):");
  338.     fflush(stdin);
  339.     scanf("%i", &senhac1);
  340.     gotoxy(14,11); 
  341.     printf ("Digite sua senha novamente:");
  342.     gotoxy(14,12);
  343.     printf ("____________________________________________________");
  344.     fflush(stdin);
  345.     gotoxy(41,11); 
  346.     scanf ("%i", &senhac2);
  347.  
  348.         if (senhac1 == senhac2) {  // if para comparar a senha1 com a 2
  349.  
  350.             gotoxy(11,14);
  351.             printf("===========** USUARIO CADASTRADO COM SUCESSO!! **==========\n");
  352.             gotoxy(11,16);
  353.             printf("================** BEM VINDO A RIFA!! **===================");
  354.             sleep(2);
  355.  
  356.         } else if (senhac1 != senhac2) {
  357.             gotoxy(14,13);
  358.             printf("Suas senhas nao combinam!\n\n");
  359.             gotoxy(14,15);
  360.             printf("Aperte S para tentar novamente");
  361.             fflush(stdin);
  362.             resp = getch();
  363.             system("cls");
  364.         }
  365.  
  366.     } while ((resp == 'S') || (resp == 's'));
  367. }
  368.  
  369. void telaloguin(void) {  // tela de loguin do usuario
  370.  
  371.     int senha1;
  372.     int senha2;
  373.     char resp2;
  374.     char nusuario;
  375.     setlocale (LC_ALL, "portuguese");
  376.  
  377.  
  378.     do {
  379.         resp2 = 'n';
  380.         system("cls");
  381.         molduratela();
  382.         gotoxy(4,3);
  383.         printf("\t   =================** LOGUIN! **=================\n\n");
  384.         gotoxy(14,5);
  385.         printf ("__________________________________________");
  386.         gotoxy(14,7);
  387.         printf("Nome de usuario:");
  388.         fflush(stdin);
  389.         scanf("%c", &nusuario);
  390.         gotoxy(14,9);
  391.         printf("Senha numerica:");
  392.         fflush(stdin);
  393.         scanf("%i", &senha1);
  394.         gotoxy(14,13);
  395.         printf ("__________________________________________");
  396.         gotoxy(14,11);
  397.         printf("Por seguranca repita sua senha:");
  398.         fflush(stdin);
  399.         scanf("%i", &senha2);
  400.  
  401.         if (senha1 == senha2) {  //comparando senhas de loguin.
  402.  
  403.            
  404.             gotoxy(11,15);
  405.             printf("===========** FEITO COM SUCESSO **=============\n\n");
  406.             sleep(2);  //pausando o sistema por 2 (2) segundos
  407.  
  408.         } else if (senha1 != senha2) {  //comparando senhas em caso de erro.
  409.  
  410.             system("cls");
  411.             printf("SUA SENHA ESTA INCORRETA!!!");
  412.             printf("\n\n aperte S para tentar novamente, ou N para sair");
  413.             sleep(2);
  414.             fflush(stdin);
  415.             resp2 = getch();
  416.             system("cls");
  417.         }
  418.     } while ((resp2 == 'S') || (resp2 == 's'));
  419. }
  420.  
  421. main() {
  422.     system("color 3f");  //mundando cor do terminal
  423.     system("title RIFA BATUTA STONKS");
  424.     int menu1;
  425.     printf(MENUPRINCIPAL);
  426.     fflush(stdin);
  427.     scanf("%i", &menu1);
  428.  
  429.     while (menu1 != 0) {  //adiocando loop de menu
  430.         system("cls");
  431.         switch (menu1) {  //executa os cases de acordo com o valor atribuido a variavel menu1.
  432.             case 1:       //Instruções caso a escolha seja "1"
  433.                 telacadastro();
  434.                 printf(CONTINUAR);
  435.                 fflush(stdin);
  436.                 getch();
  437.                 telaloguin();
  438.                 printf(CONTINUAR);
  439.                 fflush(stdin);
  440.                 getch();
  441.                 menu2();
  442.                 break;
  443.             case 2:  //Instruções caso a escolha seja "2"
  444.                 telaloguin_ADM();
  445.                 printf(CONTINUAR);
  446.                 menu_ADM();
  447.                 fflush(stdin);
  448.                 getch();
  449.                 printf(CONTINUAR);
  450.                 break;
  451.  
  452.             default:  //Instruções caso a escolha não esteja listada
  453.                 printf("\nDigite uma opcao valida\n");
  454.                 printf(CONTINUAR);
  455.                 fflush(stdin);
  456.                 getch();
  457.         }
  458.  
  459.         system("cls");
  460.         printf(MENUPRINCIPAL);
  461.         fflush(stdin);
  462.         scanf("%i", &menu1);
  463.     }
  464. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement