diff --git a/课程设计.exe b/课程设计.exe deleted file mode 100644 index 22ef041..0000000 Binary files a/课程设计.exe and /dev/null differ diff --git a/课程设计.c b/课程设计2.c similarity index 65% rename from 课程设计.c rename to 课程设计2.c index 8e92d9d..c551eee 100644 --- a/课程设计.c +++ b/课程设计2.c @@ -5,10 +5,10 @@ #include #include #include -#include +#include int main() { - system("color f4"); + system("color f4"); struct BOOK { char title[20]; @@ -59,49 +59,78 @@ int main() strcpy( book[4].time, "2011Äê6ÔÂ"); book[4].price=39.50; strcpy( book[4].locate, "¶þÂ¥302"); - - char title[20],author[20]; - char *str=title; - char *ptr=author; - int i; - char password[100]; - - - - { - int num=0; - - printf("***************»¶Ó­À´µ½ÉîÒ¹Êéµê´æ»õÇåµ¥¹ÜÀíϵͳµÇ¼½çÃæ***************\n"); - printf(" ÇëÊäÈëÃÜÂë"); - - while(1) //µÇ¼ϵͳÃÜÂë + + + struct user + { + char user_name[100]; + char user_pass[100]; + }stu[2]={{"xiaocong001","123456"},{"zhuzhu002","123456"}}; + int num1=0; + int num2=0; + printf("***************»¶Ó­À´µ½ÉîÒ¹Êéµê´æ»õÇåµ¥¹ÜÀíϵͳµÇ¼½çÃæ***************\n"); //µÇ¼ϵͳ + while(1) + { + printf("\t\tÇëÊäÈëÄúµÄÓû§Ãû£º"); + char u[100]; + + scanf("%s",u); + + if(strcmp(stu[0].user_name,u)==0||strcmp(stu[1].user_name,u)==0) + { + break; + } + + else{ + printf("²»´æÔÚ´ËÓû§£¡ÇëÖØÐÂÊäÈ룡\n"); + num1++; + if(num1==3) + { + printf("\n\t\tºÜ±§Ç¸£¬ÄúûÓÐȨÏÞ½øÈëϵͳ£¡\n"); + exit(0); } + } + } + system("cls"); + printf("***************»¶Ó­À´µ½ÉîÒ¹Êéµê´æ»õÇåµ¥¹ÜÀíϵͳµÇ¼½çÃæ***************\n"); + printf("\t\tÇëÊäÈëÃÜÂ룺"); + while(1) { - scanf("%s",password); - if(strcmp(password,"123456")==0) + char p[100]; + scanf("%s",p); + if(strcmp(stu[0].user_pass,p)==0) { printf(" µÇ¼³É¹¦\n"); break; }else { printf(" ÃÜÂë´íÎó£¬ÇëÖØÐÂÊäÈë"); - num++; - if(num==3) + num2++; + if(num2==3) { printf("ÃÜÂëÊäÈë´íÎ󳬹ýÈý´Î£¬ÏµÍ³¼´½«¹Ø±Õ"); - exit(0); + exit(0); } } } - system("cls"); //Ë¢ÆÁ - + system("cls"); //Ë¢ÆÁ + system("color e5"); + + + + + char t[20],a[20]; + int i; + printf("ÇëÊäÈëÄúҪѰÕÒµÄÊéÃûºÍ×÷Õß\n") ; - scanf("%s%s",str,ptr); + scanf("%s%s",&t,&a); for(i=0;i<5;i++) { - if(*str==*book[i].title&&*ptr==*book[i].author) + if((strcmp(t,book[i].title)==0)) { + if((strcmp(a,book[i].author)==0)) + { printf("The book is in the list."); printf( "ÊéÃû : %s\n", book[i].title); printf( "×÷Õß : %s\n", book[i].author); @@ -110,24 +139,21 @@ int main() printf("¿â´æ\n"); printf("ÇëÊäÈëËùÐèÊýÁ¿:"); int n; - scanf("%d",n); + scanf("%d",&n); if(n>(book[i].base)) { printf("ËùÐèÊýÁ¿²»ÔÚ¿â´æ·¶Î§ÄÚ"); + } + else + { + book[i].base=book[i].base - n; + printf("ÒÑÑ¡¶¨%d ±¾ %s\n",n,book[i].title); } } } + } return 0; } -} -/*void printBook( struct BOOK *book) -{ - printf( "Book title : %s\n", book->title); - printf( "Book author : %s\n", book->author); - printf( "Book publice : %s\n", book->publice); - printf( "Book time : %s\n", book->time); -} -*/ diff --git a/课程设计2.exe b/课程设计2.exe new file mode 100644 index 0000000..f7fa507 Binary files /dev/null and b/课程设计2.exe differ