![]() |
如何用C語言寫出*字號的密碼程式
設計「通關密碼的程式」,密碼為「kkm□thank□ok□!」,
共14 Bytes,通過密碼時顯示「恭喜過關 !」,否則顯示「密碼錯誤 !」 並繼續測試,輸入「***」可結束程式。( □代表空白字元 ) 大概是這樣的題目 |
單純的字串比對strcmp
或是strncmp,之前有接觸過 :on_22: |
try it~能用當作揀到吧
底下是從網路上抄來的,也不知道合不合用,
因為太久沒碰C&C++了,電腦也沒編譯器可用.... #include<conio.h> #include<stdio.h> #include<time.h> #include<stdlib.h> #include<string.h> #include<ctype.h> #define TRUE 1 void menu(void); void add(void); void list(void); void mod(void); void search(void); void del(void); void quit(void); struct my_struct { int studentid; char studentname[20]; char ic[10]; int age; char dob[10]; char address[50]; char phone[20]; char email[20]; char password[7],userpw; }s1; FILE *stream; void main(void) { char password[7] = "sas"; char userpw[7]; int i = 1; for(i=0;i<3;i++) { clrscr(); printf("\n"); printf("\n\t\tWelcome to Student Administration System "); printf("\n\t\t****************************************"); printf("\n"); printf("\n\t\tEnter Password: "); gets(userpw); if(strcmp(password,userpw) == 0) menu(); else printf("\n\t\tInvalid password ! Pls Try Again: _ "); getch(); } } 來源網址: http://www.dreamincode.net/forums/showtopic57944.htm |
所有時間均為台北時間。現在的時間是 04:02 AM。 |
Powered by vBulletin® 版本 3.6.8
版權所有 ©2000 - 2025, Jelsoft Enterprises Ltd.
『服務條款』
* 有問題不知道該怎麼解決嗎?請聯絡本站的系統管理員 *