diff --git a/课程设计3.c b/课程设计3.c new file mode 100644 index 0000000..140522f --- /dev/null +++ b/课程设计3.c @@ -0,0 +1,334 @@ +#include +#include +#include +#include +#include +#include +#include + +int main() { + system("color f4"); + struct BOOK { + char title[20]; + char author[20]; + char publice[20]; + char time[20]; + float price; + char locate[20]; + int base; + //Êé¼®Ãû³Æ£¬×÷Õߣ¬³ö°æÉ磬³ö°æÈÕÆÚ£¬¼Û¸ñ£¬ÔÚĿ¼ÖеÄλÖà + }; + + struct BOOK *book; + int N=21; + book=(struct BOOK*)malloc(N*sizeof(struct BOOK)); + strcpy( book[0].title, "¡¶À˳±Ö®áÛ¡·"); + strcpy( book[0].author, "Îâ¾ü"); + strcpy( book[0].publice, "ÈËÃñÓʵç³ö°æÉç"); + strcpy( book[0].time, "2016Äê5ÔÂ1ÈÕ"); + book[0].price=99.00; + strcpy( book[0].locate, "Êé¼ÜAÇø"); + book[0].base=19; + + strcpy( book[1].title, "¡¶È˼äʧ¸ñ¡·"); + strcpy( book[1].author, "Ì«Ô×ÖÎ"); + strcpy( book[1].publice, "ÏÖ´ú³ö°æÉç"); + strcpy( book[1].time, "2016Äê10ÔÂ"); + book[1].price=26.00; + strcpy( book[1].locate, "Êé¼ÜBÇø"); + book[1].base=9; + + strcpy( book[2].title, "¡¶Î§³Ç¡·"); + strcpy( book[2].author, "Ç®ÖÓÊé"); + strcpy( book[2].publice, "ÉϺ£³¿¹â³ö°æÉç"); + strcpy( book[2].time, "1947Äê"); + book[2].price=40.00; + strcpy( book[2].locate, "Êé¼ÜCÇø"); + book[2].base=49; + + + strcpy( book[3].title, "¡¶ºì¸ßÁ»¼Ò×å¡·"); + strcpy( book[3].author, "ĪÑÔ"); + strcpy( book[3].publice, "ÈËÃñÎÄѧ³ö°æÉç"); + strcpy( book[3].time, "2007Äê1ÔÂ"); + book[3].price=28.00; + strcpy( book[3].locate, "Êé¼ÜDÇø"); + book[3].base=39; + + strcpy( book[4].title, "¡¶°ÙÄê¹Â¶À¡·"); + strcpy( book[4].author, "¼ÓÎ÷ÑÇ¡¤Âí¶û¿Ë˹"); + strcpy( book[4].publice, "о­µäÎÄ»¯"); + strcpy( book[4].time, "2011Äê6ÔÂ"); + book[4].price=39.50; + strcpy( book[4].locate, "Êé¼ÜEÇø"); + book[4].base=29; + + strcpy( book[5].title,"¡¶Æ½·²µÄÊÀ½ç¡·"); + strcpy( book[5].author, "·ң"); + strcpy( book[5].publice, "±±¾©Ê®ÔÂÎÄÒÕ³ö°æÉç"); + strcpy( book[5].time, "2017Äê6ÔÂ1ÈÕ"); + book[5].price=29.90; + strcpy( book[5].locate, "¶þÂ¥302"); + book[5].base=50; + + strcpy( book[6].title,"¡¶ÀÏÈËÓ뺣¡·"); + strcpy( book[6].author, "º£Ã÷Íþ"); + strcpy( book[6].publice, "×÷¼Ò³ö°æÉç"); + strcpy( book[6].time, "2016Äê1ÔÂ1ÈÕ"); + book[6].price=13.10; + strcpy( book[6].locate, "¶þÂ¥302"); + book[6].base=50; + + strcpy( book[7].title,"¡¶ÉñÇú¡·"); + strcpy( book[7].author, "µ«¶¡"); + strcpy( book[7].publice, "ÉϺ£ÒëÎijö°æÉç"); + strcpy( book[7].time, "2011Äê1ÔÂ1ÈÕ"); + book[7].price=29.90; + strcpy( book[7].locate, "¶þÂ¥302"); + book[7].base=50; + + strcpy( book[8].title,"¡¶ÂæÍÕÏé×Ó¡·"); + strcpy( book[8].author, "ÀÏÉá"); + strcpy( book[8].publice, "Õã½­¹¤ÉÌ´óѧ³ö°æÉç"); + strcpy( book[8].time, "2017Äê8ÔÂ1ÈÕ"); + book[8].price=16.30; + strcpy( book[8].locate, "¶þÂ¥302"); + book[8].base=50; + + strcpy( book[9].title,"¡¶³¯»¨Ï¦Ê°¡·"); + strcpy( book[9].author, "³Ѹ"); + strcpy( book[9].publice, "̨º£³ö°æÉç"); + strcpy( book[9].time, "2012Äê8ÔÂ1ÈÕ"); + book[9].price=22.40; + strcpy( book[9].locate, "¶þÂ¥302"); + book[9].base=50; + + strcpy( book[10].title,"¡¶²è»¨Å®¡·"); + strcpy( book[10].author, "СÖÙÂí"); + strcpy( book[10].publice, "Î÷°²½»Í¨´óѧ³ö°æÉç"); + strcpy( book[10].time, "2017Äê8ÔÂ1ÈÕ"); + book[10].price=10.10; + strcpy( book[10].locate, "¶þÂ¥302"); + book[10].base=50; + + strcpy( book[11].title,"¡¶°ÁÂýÓëÆ«¼û¡·"); + strcpy( book[11].author, "°Â˹¶¡"); + strcpy( book[11].publice, "Î÷°²½»Í¨´óѧ³ö°æÉç"); + strcpy( book[11].time, "2017Äê1ÔÂ1ÈÕ"); + book[11].price=15.50; + strcpy( book[11].locate, "¶þÂ¥302"); + book[11].base=50; + + strcpy( book[12].title,"¡¶ºìÓëºÚ¡·"); + strcpy( book[12].author, "˹µ±´ï"); + strcpy( book[12].publice, "Î÷°²½»Í¨´óѧ³ö°æÉç"); + strcpy( book[12].time, "2017Äê7ÔÂ1ÈÕ"); + book[12].price=18.90; + strcpy( book[12].locate, "¶þÂ¥302"); + book[12].base=50; + + strcpy( book[13].title,"¡¶×ïÓë·£¡·"); + strcpy( book[13].author, "ÍÓ˼Í×Ò®·ò˹»ù"); + strcpy( book[13].publice, "Î÷°²½»Í¨´óѧ³ö°æÉç"); + strcpy( book[13].time, "2016Äê11ÔÂ10ÈÕ"); + book[13].price=27.20; + strcpy( book[13].locate, "¶þÂ¥302"); + book[13].base=50; + + strcpy( book[14].title,"¡¶Õ½ÕùÓëºÍƽ¡·"); + strcpy( book[14].author, "Áзò¡¤Íжû˹̩"); + strcpy( book[14].publice, "Î÷°²½»Í¨´óѧ³ö°æÉç"); + strcpy( book[14].time, "2016Äê11ÔÂ1ÈÕ"); + book[14].price=56.70; + strcpy( book[14].locate, "¶þÂ¥302"); + book[14].base=50; + + strcpy( book[15].title,"¡¶°ÍÀèʥĸԺ¡·"); + strcpy( book[15].author, "Óê¹û"); + strcpy( book[15].publice, "ÉϺ£ÎÄÒÕ³ö°æÉç"); + strcpy( book[15].time, "2008Äê1ÔÂ1ÈÕ"); + book[15].price=14.10; + strcpy( book[15].locate, "¶þÂ¥302"); + book[15].base=50; + + strcpy( book[16].title,"¡¶¼Ò¡·"); + strcpy( book[16].author, "°Í½ð"); + strcpy( book[16].publice, "ÈËÃñÎÄѧ³ö°æÉç"); + strcpy( book[16].time, "1981Äê9ÔÂ1ÈÕ"); + book[16].price=24.10; + strcpy( book[16].locate, "¶þÂ¥302"); + book[16].base=50; + + strcpy( book[17].title,"¡¶±ß³Ç¡·"); + strcpy( book[17].author, "Éò´ÓÎÄ"); + strcpy( book[17].publice, "±±¾©Ê®ÔÂÎÄÒÕ³ö°æÉç"); + strcpy( book[17].time, "2018Äê8ÔÂ1ÈÕ"); + book[17].price=19.70; + strcpy( book[17].locate, "¶þÂ¥302"); + book[17].base=50; + + strcpy( book[18].title,"¡¶ºìÑÒ¡·"); + strcpy( book[18].author, "ÂÞ¹ã±ó"); + strcpy( book[18].publice, "ÖйúÇàÄê³ö°æÉç"); + strcpy( book[18].time, "2017Äê9ÔÂ1ÈÕ"); + book[18].price=22.70; + strcpy( book[18].locate, "¶þÂ¥302"); + book[18].base=50; + + strcpy( book[19].title,"¡¶Äź°¡·"); + strcpy( book[19].author, "³Ѹ"); + strcpy( book[19].publice, "°²»Õ½ÌÓý³ö°æÉç"); + strcpy( book[19].time, "2015Äê1ÔÂ1ÈÕ"); + book[19].price=15.40; + strcpy( book[19].locate, "¶þÂ¥302"); + book[19].base=50; + + strcpy( book[20].title,"¡¶»î×Å¡·"); + strcpy( book[20].author, "Ó໪"); + strcpy( book[20].publice, "×÷¼Ò³ö°æÉç"); + strcpy( book[20].time, "2012Äê8ÔÂ1ÈÕ"); + book[20].price=15.30; + strcpy( book[20].locate, "¶þÂ¥302"); + book[20].base=50; + + + + 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) { + char p[100]; + scanf("%s",p); + if(strcmp(stu[0].user_pass,p)==0) { + printf(" µÇ¼³É¹¦\n"); + break; + } else { + if(num2!=2) { + printf("\tÃÜÂë´íÎó£¬ÇëÖØÐÂÊäÈë:"); + } + num2++; + if(num2==3) { + printf("\n"); + printf("ÃÜÂëÊäÈë´íÎ󳬹ýÈý´Î£¬ÏµÍ³3Ãëºó½«¹Ø±Õ\n"); + Sleep(1000); + printf("3\n"); + Sleep(1000); + printf("2\n"); + Sleep(1000); + printf("1\n"); + exit(0); + } + } + } + system("cls"); //Ë¢ÆÁ + system("color e5"); + + char t[20],a[20]; + int i; + float sum[100]= {0}; + + + while(1) { + int n=0; + int j=0; + printf("\t\t***************************************\n"); + printf("\t\t*ÈçÐèÍ˳öÊäÈë´øÓÐ'*'µÄÈÎÒâÁ½¸ö×Ö·û´®¡£*\n"); + printf("\t\t*eg:'* *' *\n"); + printf("\t\t***************************************\n\n\n"); + printf("ÇëÊäÈëÄúÒªËÑÑ°µÄÊéÃûÓëÖøÕß:\n") ; + + scanf("%s%s",&t,&a); + if((*t=='*')||(*a=='*')) { + printf("\t\tÇëÇóÍ˳öϵͳ³É¹¦\n"); + break; + } + for(i=0; i<21; i++) { + if((strcmp(t,book[i].title)==0)||strcmp(t,book[i].author)==0) { + if((strcmp(a,book[i].author)==0)||strcmp(a,book[i].title)==0) { + printf("\t|-----------------------------------\n"); + printf("\t|***********ÊéÄ¿ÔÚÇåµ¥ÄÚ***********|\n"); + printf("\t|ÊéÃû :%20s |\n", book[i].title); + printf("\t|ÖøÕß :%20s |\n", book[i].author); + printf("\t|³ö°æÉç :%20s |\n", book[i].publice); + printf("\t|³ö°æʱ¼ä :%20s |\n", book[i].time); + printf("\t|¼Û¸ñ :%20.2f |\n",book[i].price); + printf("\t|λÖà :%20s |\n",book[i].locate); + printf("\t|¿â´æ :%20d |\n",book[i].base); + printf("\t-----------------------------------|\n"); + printf("ÇëÊäÈëËùÐèÊýÁ¿:"); + int num; + int m=1; + while(m==1) { + scanf("%d",&num); + if(num<0) { + printf("ÊäÈëÓÐÎó.\n"); + printf("ÇëÈëÕýÈ·µÄÊýÖµ£º"); + } else if(num<=book[i].base) { + book[i].base=book[i].base - num; + printf("\n\n\t\tÒÑÑ¡¶¨%d ±¾ %s\n",num,book[i].title); + sum[i]=num*book[i].price; + printf("\t\tËùÐèÖ§¸¶µÄ½ð¶î:%.2f\n\n\n",sum[i]); + m=0; + } else { + printf("ËùÐèÊýÁ¿²»ÔÚ¿â´æ·¶Î§ÄÚ\n"); + printf("ÇëÊäÈë¿â´æÒÔÄÚµÄÊýÁ¿£º"); + + } + } + n=1; + } + + } + + } + if(n==0) { + printf("\tÇëÊäÈëÕýÈ·µÄÊéÃûÒÔ¼°¶ÔÓ¦µÄ×÷Õß¡£\n"); + } + printf("\t\t*Çë¼ÌÐøÌôÑ¡ËùÐèÊé¼®¡£\t*\n\t\t*Èç¹û²»ÐèÒªÇëÍ˳ö¡£\t*\n"); + printf("\n"); + } + float s=0.0; + for(i=0; i<21; i++) + s+=sum[i]; + printf("\t\t\t\t×ܹ²ÐèÖ§¸¶£º%.2f\n",s); + Sleep(3000); + system("cls"); + system("color f6"); + Sleep(1000); + printf("\t\t\t\t»¶Ó­Ï´ιâÁÙÉîÒ¹Êéµê¡£\n"); + Sleep(1000); + printf("\t\t\t\tÊéÖи㲻ºÃûÓлƽðÎÝ Ç§ÖÓËÚ\n"); + Sleep(1000); + printf("\t\t\t\tÑÕÈçÓñ\n"); + Sleep(1000); + printf("\t\t\t\t¿ÉÊéµê ÓÐÄã°¡"); + return 0; +} + + diff --git a/课程设计3.exe b/课程设计3.exe new file mode 100644 index 0000000..2934d29 Binary files /dev/null and b/课程设计3.exe differ