Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <locale.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h> //biblioteca para comparar strings.
- #include <time.h> // biblioteca para uso de funcional de srand.
- #include <windows.h>
- #define senha_ADM 4321
- #define loguin_ADM "stonks"
- #define setlocale (LC_ALL, "portuguese");
- #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:"
- #define CONTINUAR "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nAPERTE ENTER PARA CONTINUAR. "
- void gotoxy(int x, int y) { //void para utilizar o gotoxy
- COORD coord;
- coord.X = x;
- coord.Y = y;
- SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
- }
- void telasorteio(void) { //void com a tela de sorteio
- int i = 0;
- for(i=0; i < 41; i++ ){
- printf("%c", 220);
- }
- printf("\n");
- printf("%c",219 );
- printf("\tOS NUMEROS DOS GANHADORES SAO...%c\n",219);
- printf("%c\t\t\t\t %c\n",219, 219);
- printf("%c", 219);
- for(i=0; i < 39; i++ ){
- printf("%c", 220);
- }
- printf("%c", 219);
- }
- void sorteio(void) { //sorteio de um numero aleatorio
- srand(time(NULL));
- telasorteio();
- // sorteia o nro
- gotoxy(15, 2);
- printf("%d %d ", rand()%69 + 1 , rand ()%69+1);
- printf("\n\n\n\n\n"CONTINUAR);
- }
- void telaloguin_ADM(void) { // tela de loguin do adm
- int senhaADM2;
- char loguin_ADM2[10];
- char resp_ADM;
- setlocale (LC_ALL, "portuguese");
- system("cls");
- do { //repeticao para caso de erro no loguin
- resp_ADM = 'n';
- system("cls");
- molduratela(); //chamando a moldura da tela
- resp_ADM = 'n';
- gotoxy(1, 2);
- printf(" =========================** AREA DO ADMINISTRADOR **========================\n\n");
- gotoxy(4, 4);
- printf("Nome de usuario ADM:");
- fflush(stdin);
- scanf("%s", &loguin_ADM2);
- gotoxy(4, 6);
- printf("Sua senha numerica:");
- fflush(stdin);
- scanf("%i", &senhaADM2);
- if (strcmp(loguin_ADM2, loguin_ADM) != 0) { // comparando strings com strcmp, resto 0 = strings iguais, resto !=(diferente) 0 strings diferentes.
- system("cls");
- gotoxy(10,2);
- printf("================** SOMENTE ADMINISTRADORES!! **===================");
- gotoxy(13,6);
- printf("Sua credencial esta errada!\n\n");
- gotoxy(13,10);
- printf("Aperte S para tentar novamente");
- fflush(stdin);
- resp_ADM = getch();
- system("cls");
- telaloguin_ADM(); //chamando tela de loguin do adm novamente em caso de erro da credencial.
- }
- if (senhaADM2 == senha_ADM) { //comparado senhas / senha_ADM prefinida
- gotoxy(4, 8);
- printf("Loguin feito com sucesso!");
- sleep(3);
- system("cls");
- menu_ADM(); // chamando menu de adm.
- } else if (senhaADM2 != senha_ADM) { //comparando senhas para caso houver erro.
- system("cls");
- gotoxy(10,2);
- printf("================** SOMENTE ADMINISTRADORES!! **===================");
- gotoxy(13,6);
- printf("Suas senhas nao combinam!\n\n");
- gotoxy(13,10);
- printf("Aperte S para tentar novamente!");
- fflush(stdin);
- resp_ADM = getch();
- system("cls");
- }
- } while ((resp_ADM == 'S') || (resp_ADM == 's')); //repeticao de loop
- }
- void menu_ADM(void) { //void ta dela de menu do adm
- char opADM;
- setlocale (LC_ALL, "portuguese");
- system("cls");
- molduratela();
- gotoxy(12,8);
- printf("___________________");
- gotoxy(12,3);
- printf("___________________");
- gotoxy(7,2);
- printf(" ===================** AREA DO ADMINISTRADOR **===================\n\n");
- gotoxy(12,5);
- printf("1 - Sorteio.");
- gotoxy(12,7);
- printf("2 - Sair.");
- gotoxy(12,10);
- printf("Qual sua escolha:");
- fflush(stdin);
- opADM = getch();
- if (opADM == '1') {
- system("cls");
- sorteio();
- } else if (opADM == '2') {
- system("cls");
- main();
- }
- }
- void telarifa (void) {
- system("cls");
- char op2;
- int cont, cont25;
- cont = 1;
- while (cont < 51){
- if (cont >=1 && cont<=9){
- printf ("0");
- }
- printf("%i ", cont);
- if (cont %10 == 0){
- printf("\n");
- }
- cont = cont + 1;
- }
- printf ("APERTE 0 PARA VOLTAR OU ENTER PARA SAIR");
- fflush(stdin);
- op2=getch();
- if (op2 == '0'){
- system("cls");
- menu2();
- }
- }
- void menu2(void) { //void para o menu2 pós cadastro/loguin
- char op;
- setlocale (LC_ALL, "portuguese");
- system("cls");
- gotoxy (15,4);
- printf("** BEM VINDO! **\n\n");
- gotoxy(12,6);
- 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);
- gotoxy (12,6);
- printf("%c", 219);
- gotoxy (12,7);
- printf("%c", 219);
- gotoxy (12,8);
- printf("%c", 219);
- gotoxy (12,9);
- printf("%c", 219);
- gotoxy (12,10);
- printf("%c", 219);
- gotoxy (12,11);
- printf("%c", 219);
- gotoxy (12,12);
- printf("%c", 219);
- gotoxy (12,13);
- printf("%c", 219);
- gotoxy (12,14);
- printf("%c", 219);
- gotoxy (12,15);
- printf("%c", 219);
- gotoxy (12,16);
- printf("%c", 219);
- gotoxy (12,17);
- printf("%c", 219);
- gotoxy (12,18);
- printf("%c", 219);
- gotoxy(12,19);
- 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);
- gotoxy (45,6);
- printf("%c", 219);
- gotoxy(45,7);
- printf("%c", 219);
- gotoxy (45,8);
- printf("%c", 219);
- gotoxy (45,9);
- printf("%c", 219);
- gotoxy (45,10);
- printf("%c", 219);
- gotoxy (45,11);
- printf("%c", 219);
- gotoxy (45,12);
- printf("%c", 219);
- gotoxy (45,13);
- printf("%c", 219);
- gotoxy (45,14);
- printf("%c", 219);
- gotoxy (45,15);
- printf("%c", 219);
- gotoxy (45,16);
- printf("%c", 219);
- gotoxy (45,17);
- printf("%c", 219);
- gotoxy (45,18);
- printf("%c", 219);
- gotoxy (21, 9);
- printf("\t1 = TelaRifa.");
- gotoxy(21,13);
- printf("\t2 = Saida.");
- gotoxy(16,17);
- printf("Pressione para prosseguir:");
- fflush(stdin);
- op = getch();
- if (op == '1') {
- system("cls");
- printf("\n\n\n\n\n\n\n\n\n\n\n");
- telarifa();
- } else if (op == '2') {
- system("cls");
- main();
- }
- }
- void molduratela(void) { //void para moldura das telas
- int i, j, l, k; //variaveis para receber o código ASCII
- setlocale (LC_ALL, "portuguese");
- for (i = 0; i < 79; i++) {
- printf("%c", 220);
- }
- printf("\n");
- for (j = 0; j < 9; j++) {
- printf("%c", 219);
- for (i = 0; i < 77; i++) {
- printf(" ");
- }
- printf("%c\n", 219);
- }
- printf("%c", 219);
- for (i = 0; i < 26; i++) {
- printf(" ");
- }
- printf(" ");
- for (i = 0; i < 26; i++) {
- printf(" ");
- }
- printf("%c\n", 219);
- for (j = 0; j < 9; j++) {
- printf("%c", 219);
- for (i = 0; i < 77; i++) {
- printf(" ");
- }
- printf("%c\n", 219);
- }
- printf("%c", 219);
- for (i = 0; i < 77; i++) {
- printf("%c", 220);
- }
- printf("%c", 219);
- printf("\n");
- }
- void telacadastro() { //void para tela de cadastro
- int senhac1, senhac2, senhal;
- char loguin, resp;
- setlocale (LC_ALL, "portuguese");
- molduratela();
- gotoxy(18, 5);
- do {
- system("cls");
- molduratela();
- resp = 'n';
- gotoxy(4,3);
- printf("\t =======================** CADASTRO **=======================\n\n");
- gotoxy(14,5);
- printf("____________________________________________________");
- gotoxy(10,7);
- printf(" Escolha seu nome de usuario:");
- fflush(stdin);
- scanf("%c", &loguin);
- gotoxy(14,9);
- printf("Escolha sua senha (somente com numeros):");
- fflush(stdin);
- scanf("%i", &senhac1);
- gotoxy(14,11);
- printf ("Digite sua senha novamente:");
- gotoxy(14,12);
- printf ("____________________________________________________");
- fflush(stdin);
- gotoxy(41,11);
- scanf ("%i", &senhac2);
- if (senhac1 == senhac2) { // if para comparar a senha1 com a 2
- gotoxy(11,14);
- printf("===========** USUARIO CADASTRADO COM SUCESSO!! **==========\n");
- gotoxy(11,16);
- printf("================** BEM VINDO A RIFA!! **===================");
- sleep(2);
- } else if (senhac1 != senhac2) {
- gotoxy(14,13);
- printf("Suas senhas nao combinam!\n\n");
- gotoxy(14,15);
- printf("Aperte S para tentar novamente");
- fflush(stdin);
- resp = getch();
- system("cls");
- }
- } while ((resp == 'S') || (resp == 's'));
- }
- void telaloguin(void) { // tela de loguin do usuario
- int senha1;
- int senha2;
- char resp2;
- char nusuario;
- setlocale (LC_ALL, "portuguese");
- do {
- resp2 = 'n';
- system("cls");
- molduratela();
- gotoxy(4,3);
- printf("\t =================** LOGUIN! **=================\n\n");
- gotoxy(14,5);
- printf ("__________________________________________");
- gotoxy(14,7);
- printf("Nome de usuario:");
- fflush(stdin);
- scanf("%c", &nusuario);
- gotoxy(14,9);
- printf("Senha numerica:");
- fflush(stdin);
- scanf("%i", &senha1);
- gotoxy(14,13);
- printf ("__________________________________________");
- gotoxy(14,11);
- printf("Por seguranca repita sua senha:");
- fflush(stdin);
- scanf("%i", &senha2);
- if (senha1 == senha2) { //comparando senhas de loguin.
- gotoxy(11,15);
- printf("===========** FEITO COM SUCESSO **=============\n\n");
- sleep(2); //pausando o sistema por 2 (2) segundos
- } else if (senha1 != senha2) { //comparando senhas em caso de erro.
- system("cls");
- printf("SUA SENHA ESTA INCORRETA!!!");
- printf("\n\n aperte S para tentar novamente, ou N para sair");
- sleep(2);
- fflush(stdin);
- resp2 = getch();
- system("cls");
- }
- } while ((resp2 == 'S') || (resp2 == 's'));
- }
- main() {
- system("color 3f"); //mundando cor do terminal
- system("title RIFA BATUTA STONKS");
- int menu1;
- printf(MENUPRINCIPAL);
- fflush(stdin);
- scanf("%i", &menu1);
- while (menu1 != 0) { //adiocando loop de menu
- system("cls");
- switch (menu1) { //executa os cases de acordo com o valor atribuido a variavel menu1.
- case 1: //Instruções caso a escolha seja "1"
- telacadastro();
- printf(CONTINUAR);
- fflush(stdin);
- getch();
- telaloguin();
- printf(CONTINUAR);
- fflush(stdin);
- getch();
- menu2();
- break;
- case 2: //Instruções caso a escolha seja "2"
- telaloguin_ADM();
- printf(CONTINUAR);
- menu_ADM();
- fflush(stdin);
- getch();
- printf(CONTINUAR);
- break;
- default: //Instruções caso a escolha não esteja listada
- printf("\nDigite uma opcao valida\n");
- printf(CONTINUAR);
- fflush(stdin);
- getch();
- }
- system("cls");
- printf(MENUPRINCIPAL);
- fflush(stdin);
- scanf("%i", &menu1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement