C/Academy
C언어 간단한 로그인 프로그램
갈릭새우칩
2019. 6. 25. 21:41
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | #include <stdio.h> #include <stdlib.h> const int SUCCESS = 1; const int FAIL = 2; const int LIMIT = 3; const int AdminID = 8613; const int AdminPass = 3090; int LoginCount = 0; int check(int id, int password); int check(int id, int password) { LoginCount++; if (LoginCount == LIMIT) { return LIMIT; } if (AdminID == id && AdminPass == password) { return SUCCESS; } if (AdminID != id || AdminPass != password) { return FAIL; } } int main(void) { int id, password, result; while (1) { printf("id:____\b\b\b\b"); scanf("%d", &id); printf("pass:____\b\b\b\b"); scanf("%d", &password); result = check(id, password); if (result == SUCCESS) { printf("로그인 성공\n"); break; } if (result == FAIL) { printf("ID or PASSWORD ERROR!\n"); } if (result == LIMIT) { printf("횟수초과!!!\n"); break; } } return 0; } | cs |