缁忔祹瑙傚療
杩愯惀绠$悊

c璇█ 瀛︾敓淇℃伅绠$悊绯荤粺

c璇█ 瀛︾敓淇℃伅绠$悊绯荤粺

瀛︾敓淇℃伅绠$悊绯荤粺c璇█

#include锛俿tdio.h锛?include锛俢onio.h锛?include锛俿tring.h锛?include锛俿tdlib.h锛?void look锛?锛?/*澹版槑鏌ョ湅鍑芥暟*/ void save锛?锛?/*澹版槑淇濆瓨鍑芥暟*/ void search_name锛?锛?/*澹版槑鎸夊鍚嶆煡鐪嬪嚱鏁?/ void search_number锛?锛?/*澹版槑鎸夊鍙锋煡鐪嬪嚱鏁?/ void order锛?锛?/*澹版槑鎺掑簭鍑芥暟*/ void del锛?锛?/*澹版槑鍒犻櫎鍑芥暟*/ int openl锛?锛?/*澹版槑鎵撳紑鍑芥暟*/ void welcome锛?锛?/*澹版槑鎴戠殑涓汉淇℃伅鍑芥暟*/ void type锛?锛?/*澹版槑杈撳叆鍑芥暟*/ void see锛?锛?/*澹版槑鎵撳紑骞舵煡鐪嬫枃浠跺嚱鏁?/ struct student /*瀹氫箟瀛︾敓淇℃伅鐨勭粨鏋勪綋绫诲瀷*/ { char num[15]锛?/*瀛﹀彿*/ char name[20]锛?/*濮撳悕*/ char sex[4]锛?/*鎬у埆*/ int english锛?/*鑻辫鎴愮哗*/ int math锛?/*鏁板鎴愮哗*/ int chinese锛?/*璇枃鎴愮哗*/ float aver锛?/*骞冲潎鎴愮哗*/ float sum锛?/*鎬绘垚缁?/ }stu[100]; int n锛?/*澹版槑涓€涓叏灞€鍙橀噺*/ void main锛? /*涓诲嚱鏁板嵆鐢ㄦ埛鐨勬搷浣滅晫闈?/ { system(锛俢olor 1E锛?锛?/*璁捐鏂囨湰棰滆壊*/ int b,flag=0锛?/*澹版槑灞€閮ㄥ彉閲?/ while(1) /*寰幆杈撳嚭浠ヤ笅淇℃伅*/ { printf(锛俓n\t\t\t娆㈣繋鏉ュ埌瀛︾敓鎴愮哗绠$悊绯荤粺锛乗n锛?; printf(锛俓n\t\t\t\t ###鍒朵綔\n锛?; printf(锛俓t\t\t-------------------------------\n锛?; printf(锛俓t\t\t1.閿叆瀛︾敓鐨勪俊鎭痋n\n锛?锛?/*閿叆瀛︾敓鐨勪俊鎭?/ printf(锛俓t\t\t2.鏌ョ湅褰曞叆鐨勫鐢熶俊鎭痋n\n锛?锛?/*鏌ョ湅褰曞叆鐨勫鐢熶俊鎭?/ printf(锛俓t\t\t3.鎸夊鍚嶆煡鐪嬪鐢熺殑淇℃伅\n\n锛?锛?/*鎸夊鍚嶆煡鐪嬪鐢熺殑淇℃伅*/ printf(锛俓t\t\t4.鎸夊鍙锋煡鐪嬪鐢熺殑淇℃伅\n\n锛?锛?/*鎸夊鍙锋煡鐪嬪鐢熺殑淇℃伅*/ printf(锛俓t\t\t5.鎸夊钩鍧囨垚缁╂帓搴廫n\n锛?锛?/*鎺掑簭*/ printf(锛俓t\t\t6.鍒犻櫎瀛︾敓淇℃伅\n\n锛?锛?/*鍒犻櫎瀛︾敓淇℃伅*/ printf(锛俓t\t\t7.淇濆瓨瀛︾敓淇℃伅\n\n锛?锛?/*淇濆瓨*/ printf(锛俓t\t\t8.鎵撳紑鏂囦欢\n\n锛?锛?/*鎵撳紑鏂囦欢*/ printf(锛俓t\t\t9.鎴戠殑涓汉淇℃伅\n\n锛?锛?/*鎴戠殑涓汉淇℃伅*/ printf(锛俓t\t\t0.閫€鍑篭n\n锛?锛?/*閫€鍑?/ printf(锛俓t\t\t璇疯緭鍏ヤ綘鐨勯€夋嫨锛氾紓)锛?scanf(锛?d锛?&b); switch(b) { case 1:type();break锛?/*璋冪敤閿叆瀛︾敓淇℃伅鍑芥暟*/ case 2:look();break锛?/*璋冪敤鏌ョ湅鍑芥暟*/ case 3:search_name();break锛?/*璋冪敤濮撳悕鏌ョ湅鍑芥暟*/ case 4:search_number();break锛?/*璋冪敤瀛﹀彿鏌ョ湅鍑芥暟*/ case 5:order();break锛?/*璋冪敤鎺掑簭鍑芥暟*/ case 6:del();break锛?*璋冪敤鍒犻櫎鍑芥暟*/ case 7:save();break锛?*璋冪敤淇濆瓨鍑芥暟*/ case 8:see();break锛?*璋冪敤鎵撳紑鏂囦欢鍑芥暟*/ case 9:welcome();break锛?*璋冪敤鎴戠殑涓汉淇℃伅鍑芥暟*/ case 0:flag=1;break锛?*閫€鍑篠WITCH璇彞*/ default :printf锛堬紓閿欒锛侊紓锛夛紱 } if(flag) break锛?/*濡傛灉閫夋嫨0灏遍€€鍑哄惊鐜?/ } } void welcome锛? /*鎴戠殑涓汉淇℃伅鍑芥暟*/ { system(锛侰LS锛?; printf(锛俓n\n\t\t------------涓汉淇℃伅------------锛?锛?/*鍦ㄥ睆骞曚笂杈撳嚭涓€涓嬩俊鎭?/ printf(锛俓n\n\n\n\t\t濮撳悕锛?##锛?锛?printf(锛俓t\t\tSex:#\n锛?; printf(锛俓t\t骞撮緞锛?\n锛?; printf(锛俓n\t\t\t--------瀛︿範缁忓巻--------\n\n\n锛?; printf(锛俓t\t灏忓锛?#####\n\n锛?; printf(锛俓t\t鍒濅腑锛?####\n\n锛?; printf(锛俓t\tS楂樹腑锛?#####\n\n锛?; printf(锛俓t\t澶у锛?#####\n\n锛?; printf(锛俓n\n\t\t鎸変换鎰忛敭杩斿洖娆㈣繋灞忓箷锛侊紓)锛?getch锛?锛?/*鎸変换鎰忛敭杩斿洖涓诲嚱鏁?/ } void type锛? /*瀹氫箟閿叆瀛︾敓淇℃伅鍑芥暟*/ { system(锛侰LS锛?; int i锛?/*瀹氫箟灞€閮ㄥ彉閲?/ printf(锛俓t\t杈撳嚭浣犳兂杈撳叆鐨勫鐢熶俊鎭釜鏁帮細锛?锛?scanf(锛?d锛?&n); for(i=0;i { printf(锛俓n\t\t\t----------------\n锛?; printf(锛俓t\t\t瀛﹀彿锛氾紓)锛?scanf(锛?s锛?&stu[i].num)锛?/*杈撳叆瀛﹀彿*/ printf(锛俓t\t\t濮撳悕锛氾紓)锛?scanf(锛?s锛?&stu[i].name)锛?/*杈撳叆濮撳悕*/ printf(锛俓t\t\t鎬у埆锛氾紓)锛?scanf(锛?S锛?&stu[i].sex)锛?/*杈撳叆鎬у埆*/ printf(锛俓t\t\t鑻辫锛氾紓)锛?scanf(锛?d锛?&stu[i].english)锛?/*杈撳叆鑻辫鎴愮哗*/ printf(锛俓t\t\t鏁板锛氾紓)锛?scanf(锛?d锛?&stu[i].math)锛?/*杈撳叆鏁板鎴愮哗*/ printf(锛俓t\t\t璇枃锛氾紓)锛?scanf(锛?d锛?&stu[i].chinese)锛?/*杈撳叆璇枃鎴愮哗*/ stu[i].aver=((float)stu[i].english+(float)stu[i].math+(float)stu[i].chinese)/3锛?*璁$畻骞冲潎鎴愮哗*/ stu[i].sum=(float)stu[i].english+(float)stu[i].math+(float)stu[i].chinese锛?*璁$畻鎬绘垚缁?/ printf(锛俓t\t\t骞冲潎鎴愮哗=%4.1f\n锛?stu[i].aver)锛?/*杈撳嚭骞冲潎鎴愮哗*/ printf(锛俓t\t\t鎬绘垚缁?%4.1f\n锛?stu[i].sum)锛?/*杈撳嚭鎬绘垚缁?/ } printf(锛俓n\n\t\t\t鎸変换鎰忛敭杩斿洖鑿滃崟锛侊紒锛?锛?getch(); save(); } void save锛? /*寤虹珛淇濆瓨鏂囦欢鍑芥暟*/ { system(锛侰LS锛?; FILE *fp锛?/*瀹氫箟鏂囦欢鍨嬫寚閽?/ int i; if((fp=fopen(锛俿tudent.txt锛?锛倃b锛?)==NULL锛?/*鎵撳紑杈撳嚭鏂囦欢*/ { printf锛堬紓涓嶈兘鎵撳紑鏂囦欢锛乗n锛傦級; return锛?/*缁堟绋嬪簭*/ } for(i=0;i if(fwrite(&stu[i],sizeof(struct student),1,fp)!=1) printf锛堬紓鏂囦欢鍐欏叆閿欒\n锛傦級; fclose(fp)锛?/*鍏抽棴鏂囦欢*/ printf(锛俓n\n\n\n\t\t\t瀛︾敓淇℃伅淇濆瓨鎴愬姛锛乗n锛?; printf(锛俓n\n\n\n\t\t\t鎸変换鎰忛敭杩斿洖鑿滃崟锛侊紒锛?锛?getch(); } void look锛? /*瀹氫箟鏌ョ湅鍑芥暟*/ { system(锛侰LS锛?; int i; //n=openl锛?锛?/*璋冪敤openl鍑芥暟*/ printf(锛俓t瀛﹀彿\t濮撳悕\t鎬у埆\t鑻辫\t鏁板\t璇枃\t骞冲潎鎴愮哗\t鎬绘垚缁‐n锛?; for(i=0;i { printf(锛?10s\t%s\t%2s\t%d\t%d\t%d\t%3.1f\t\t%6.1f\n锛?stu[i].num,stu[i].name, stu[i].sex,stu[i].english,stu[i].math,stu[i].chinese,stu[i].aver,stu[i].sum); } printf(锛俓n\n\n\t\t\t鎸変换鎰忛敭杩斿洖鑿滃崟锛?锛?getch(); } void search_name锛? /*鎸夊鍚嶆煡鐪嬪嚱鏁?/ { system(锛侰LS锛?; int i; char name[20]锛?/*澹版槑瀛楃鏁扮粍*/ printf(锛俓t\t\t璇疯緭鍏ュ鐢熷鍚嶏細\n锛?; scanf(锛?s锛?name); printf(锛俓t瀛﹀彿\t濮撳悕\t鎬у埆\t鑻?..

c璇█锛氬鐢熷绫嶇鐞嗙郴缁?/h2>

#include #include #include #include int n=0,i; struct address_book{ char name[20]; int num; int age; char place[80]; char sex; char clas[40]; char department[40]; char domain[40]; char dowhat[20];}stud[200];void add(){ char j;front1: system(锛俢ls锛?锛?/娓呭睆 printf(锛俓n璇疯緭鍏ヨ娣诲姞鐨勫鍚嶏細锛?锛?scanf(锛?s锛?stud[n].name); printf(锛俓n璇疯緭鍏ヨ娣诲姞鐨勫鍙凤紙8浣嶏級锛氾紓锛夛紱 scanf(锛?d锛?&stud[n].num); printf(锛俓n璇疯緭鍏ヨ娣诲姞鐨勬€у埆锛團/M锛?锛?; scanf(锛俓n%c锛?&stud[n].sex); printf(锛俓n璇疯緭鍏ヨ娣诲姞鐨勫勾榫勶細锛?锛?scanf(锛?d锛?&stud[n].age); printf(锛俓n璇疯緭鍏ヨ娣诲姞鐨勭彮绾э細锛?锛?scanf(锛?s锛?stud[n].clas); printf(锛俓n璇疯緭鍏ヨ娣诲姞鐨勭睄璐細锛?锛?scanf(锛?s锛?stud[n].place); printf(锛俓n璇疯緭鍏ヨ娣诲姞鐨勭郴鍒細锛?锛?scanf(锛?s锛?stud[n].department); printf(锛俓n璇疯緭鍏ヨ娣诲姞鐨勪笓涓氾細锛?锛?scanf(锛?s锛?stud[n].domain); printf(锛俓n璇疯緭鍏ュ绫嶅彉鍖栵細锛?锛?scanf(锛?s锛?stud[n].dowhat); getchar(); n++; printf锛堬紓鏄惁缁х画锛圷/N锛?:锛?; j=getchar(); getchar(); if(j=='y'||j=='Y') goto front1锛?/鍐嶆杈撳叆璁板綍} void del(){ int k=0,m,i; char j;front2: system(锛俢ls锛?锛?/娓呭睆 printf(锛俓n璇疯緭鍏ヨ鍒犻櫎鐨勫鍙凤細锛?锛?scanf(锛?d锛?&m); getchar(); for(i=0;istud[i+1].num) { t=stud[i]; stud[i]=stud[i+1]; stud[i+1]=t; } for(i=0;i<=n-1;i++) if(stud[i].num!=0) printf(锛?-10s %-8d %8c %-8d %-10s %-10s %-10s %-10s\n锛?stud[i].name,stud[i].num,stud[i].sex,stud[i].age,stud[i].clas,stud[i].place,stud[i].department,stud[i].domain); printf锛堬紓鎸夊洖杞﹂敭杩斿洖锛侊紓锛夛紱 getchar(); getchar();} void change(){ int k=0,m; char j;front5: system(锛俢ls锛?锛?/娓呭睆 printf(锛俓n璇疯緭鍏ヨ淇敼璁板綍鐨勫鍙凤細锛?锛?scanf(锛?d锛?&m); getchar(); for(i=0;i<n;i++)//鏌ユ壘 if(m==stud[i].num) { k=1; break; } if(k==1) { printf(锛俓n璇疯緭鍏ヨ淇敼鐨勫鍚嶏細锛?锛?scanf(锛?s锛?stud[i].name); printf(锛俓n璇疯緭鍏ヨ淇敼鐨勫鍙凤紙8浣嶏級锛氾紓锛夛紱 scanf(锛?d锛?&stud[i].num); printf(锛俓n璇疯緭鍏ヨ淇敼鐨勬€у埆锛團/M锛?锛?; scanf(锛?c锛?&stud[i].sex); printf(锛俓n璇疯緭鍏ヨ淇敼鐨勫勾榫勶細锛?锛?scanf(锛?d锛?&stud[i].age); printf(锛俓n璇疯緭鍏ヨ淇敼鐨勭彮绾э細锛?锛?scanf(锛?s锛?stud[i].clas); printf(锛俓n璇疯緭鍏ヨ淇敼鐨勭睄璐細锛?锛?scanf(锛?s锛?stud[i].place); printf(锛俓n璇疯緭鍏ヨ淇敼鐨勭郴鍒細锛?锛?scanf(锛?s锛?stud[i].department); printf(锛俓n璇疯緭鍏ヨ淇敼鐨勪笓涓氾細锛?锛?scanf(锛?s锛?stud[i].domain); printf(锛俓n璇疯緭鍏ヨ淇敼鐨勫绫嶅彉鍖栵細锛?锛?scanf(锛?s锛?stud[n].dowhat); getchar(); } if(k==0) { printf锛堬紓鎵句笉鍒拌淇敼鐨勮褰曪紒\n锛傦級; printf锛堬紓鎸夊洖杞﹂敭杩斿洖锛氾紓锛夛紱 getchar(); } getchar(); printf锛堬紓鏄惁缁х画锛圷/N锛?:锛?; j=getchar(); getchar(); if(j=='y'||j=='Y') goto front5;} void find(){ int k=0,m; char j;front3: system(锛俢ls锛?锛?/娓呭睆 printf(锛俓n璇疯緭鍏ヨ鏌ユ壘鐨勫鐢熺殑瀛﹀彿锛氾紓)锛?scanf(锛?d锛?&m); getchar(); for(i=0;i<n;i++)//鏌ユ壘 if(m==stud[i].num) { k=1; break; } if(k==1) { printf锛堬紓濮撳悕瀛﹀彿鎬у埆骞撮緞鐝骇绫嶈疮绯诲埆涓撲笟瀛︾睄鍙樺寲\n锛傦級; printf(锛?-8s %-8d %8c %-8d %-10s %-10s %-10s %-10s %-8s\n锛?stud[i].name,stud[i].num,stud[i].sex,stud[i].age,stud[i].clas,stud[i].place,stud[i].department,stud[i].domain,stud[i].dowhat); } else { printf锛堬紓鎵句笉鍒拌鍚屽锛佽閲嶆柊杈撳叆锛佹寜鍥炶溅杩斿洖锛侊紓锛夛紱 getchar(); goto front3; } printf锛堬紓鏄惁缁х画锛圷/N锛?:锛?; j=getchar(); getchar(); if(j=='y'||j=='Y') goto front3;} void main(){ char j; printf(锛俓n\n\n\n\n\n\t\t\t 娆㈣繋浣跨敤瀛︾敓瀛︾睄绠$悊绯荤粺锛?锛?printf(锛俓n\n\n\t\t\t\t鍒朵綔浜猴細zqr锛?; printf(锛俓n\n\n\t\t\t\t 2016骞?鏈堬紓)锛? printf(锛俓n\n\n\n\n\n\n\n\n\n\n\n鎸夊洖杞﹂敭杩涘叆涓昏彍鍗曪細锛?锛?getchar();loop: system(锛俢ls锛?; printf(锛俓n锛?; printf(锛俓t\t\t\t ************\n锛?; printf(锛俓t\t\t\t ***涓昏彍鍗?**\n锛?; printf(锛俓t\t\t\t ************\n\n\n\n\n\n锛?; printf(锛俓t\t 1銆佸綍鍏ュ鐢熶俊鎭?銆佸垹闄ゅ鐢熶俊鎭痋n\n锛?; printf(锛俓t\t 3銆佹煡鎵惧鐢熶俊鎭?銆佸鐢熶俊鎭帓搴廫n\n锛?; printf(锛俓t\t 5銆佷慨鏀瑰鐢熶俊鎭?銆佷繚瀛橀€€鍑虹郴缁焅n\n锛?; printf(锛俓n\n\n\n\n\n\n\n\n璇烽€夋嫨[1/2/3/4/5/6]:锛?; j=getchar(); if(j=='\n') goto loop锛?/杩斿洖涓昏彍鍗?switch(j) { case '1': add();goto loop锛?/杩斿洖涓昏彍鍗?case '2': del();goto loop; case '3': find();goto loop; case '4': arrange();goto loop; case '5': change();goto loop; case '6': { FILE *fp; fp=fopen(锛俿tudent.dat锛?锛倃锛?; for(i=0;i<n;i++) fwrite(&stud[i],sizeof(struct address_book),1,fp); fclose(fp); exit(0); } default: goto loop; } }

瀛︾敓淇℃伅绠$悊绯荤粺c璇█

#include锛俿tdio.h锛?include锛俢onio.h锛?include锛俿tring.h锛?include锛俿tdlib.h锛倂oid look锛?锛?/*澹版槑鏌ョ湅鍑芥暟*/void save锛?锛?/*澹版槑淇濆瓨鍑芥暟*/void search_name锛?锛?/*澹版槑鎸夊鍚嶆煡鐪嬪嚱鏁?/void search_number锛?锛?/*澹版槑鎸夊鍙锋煡鐪嬪嚱鏁?/void order锛?锛?/*澹版槑鎺掑簭鍑芥暟*/void del锛?锛?/*澹版槑鍒犻櫎鍑芥暟*/int openl锛?锛?/*澹版槑鎵撳紑鍑芥暟*/void welcome锛?锛?/*澹版槑鎴戠殑涓汉淇℃伅鍑芥暟*/void type锛?锛?/*澹版槑杈撳叆鍑芥暟*/void see锛?锛?/*澹版槑鎵撳紑骞舵煡鐪嬫枃浠跺嚱鏁?/struct student /*瀹氫箟瀛︾敓淇℃伅鐨勭粨鏋勪綋绫诲瀷*/{ char num[15]锛?/*瀛﹀彿*/ char name[20]锛?/*濮撳悕*/ char sex[4]锛?/*鎬у埆*/ int english锛?/*鑻辫鎴愮哗*/ int math锛?/*鏁板鎴愮哗*/ int chinese锛?/*璇枃鎴愮哗*/ float aver锛?/*骞冲潎鎴愮哗*/ float sum锛?/*鎬绘垚缁?/}stu[100];int n锛?/*澹版槑涓€涓叏灞€鍙橀噺*/void main锛? /*涓诲嚱鏁板嵆鐢ㄦ埛鐨勬搷浣滅晫闈?/{ system(锛俢olor 1E锛?锛?/*璁捐鏂囨湰棰滆壊*/ int b,flag=0锛?/*澹版槑灞€閮ㄥ彉閲?/ while(1) /*寰幆杈撳嚭浠ヤ笅淇℃伅*/ { printf(锛俓n\t\t\t娆㈣繋鏉ュ埌瀛︾敓鎴愮哗绠$悊绯荤粺锛乗n锛?; printf(锛俓n\t\t\t\t ###鍒朵綔\n锛?; printf(锛俓t\t\t-------------------------------\n锛?; printf(锛俓t\t\t1.閿叆瀛︾敓鐨勪俊鎭痋n\n锛?锛?/*閿叆瀛︾敓鐨勪俊鎭?/ printf(锛俓t\t\t2.鏌ョ湅褰曞叆鐨勫鐢熶俊鎭痋n\n锛?锛?/*鏌ョ湅褰曞叆鐨勫鐢熶俊鎭?/ printf(锛俓t\t\t3.鎸夊鍚嶆煡鐪嬪鐢熺殑淇℃伅\n\n锛?锛?/*鎸夊鍚嶆煡鐪嬪鐢熺殑淇℃伅*/ printf(锛俓t\t\t4.鎸夊鍙锋煡鐪嬪鐢熺殑淇℃伅\n\n锛?锛?/*鎸夊鍙锋煡鐪嬪鐢熺殑淇℃伅*/ printf(锛俓t\t\t5.鎸夊钩鍧囨垚缁╂帓搴廫n\n锛?锛?/*鎺掑簭*/ printf(锛俓t\t\t6.鍒犻櫎瀛︾敓淇℃伅\n\n锛?锛?/*鍒犻櫎瀛︾敓淇℃伅*/ printf(锛俓t\t\t7.淇濆瓨瀛︾敓淇℃伅\n\n锛?锛?/*淇濆瓨*/ printf(锛俓t\t\t8.鎵撳紑鏂囦欢\n\n锛?锛?/*鎵撳紑鏂囦欢*/ printf(锛俓t\t\t9.鎴戠殑涓汉淇℃伅\n\n锛?锛?/*鎴戠殑涓汉淇℃伅*/ printf(锛俓t\t\t0.閫€鍑篭n\n锛?锛?/*閫€鍑?/ printf(锛俓t\t\t璇疯緭鍏ヤ綘鐨勯€夋嫨锛氾紓)锛?scanf(锛?d锛?&b); switch(b) { case 1:type();break锛?/*璋冪敤閿叆瀛︾敓淇℃伅鍑芥暟*/ case 2:look();break锛?/*璋冪敤鏌ョ湅鍑芥暟*/ case 3:search_name();break锛?/*璋冪敤濮撳悕鏌ョ湅鍑芥暟*/ case 4:search_number();break锛?/*璋冪敤瀛﹀彿鏌ョ湅鍑芥暟*/ case 5:order();break锛?/*璋冪敤鎺掑簭鍑芥暟*/ case 6:del();break锛?*璋冪敤鍒犻櫎鍑芥暟*/ case 7:save();break锛?*璋冪敤淇濆瓨鍑芥暟*/ case 8:see();break锛?*璋冪敤鎵撳紑鏂囦欢鍑芥暟*/ case 9:welcome();break锛?*璋冪敤鎴戠殑涓汉淇℃伅鍑芥暟*/ case 0:flag=1;break锛?*閫€鍑篠WITCH璇彞*/ default :printf锛堬紓閿欒锛侊紓锛夛紱 } if(flag) break锛?/*濡傛灉閫夋嫨0灏遍€€鍑哄惊鐜?/ }}void welcome锛? /*鎴戠殑涓汉淇℃伅鍑芥暟*/{ system(锛侰LS锛?; printf(锛俓n\n\t\t------------涓汉淇℃伅------------锛?锛?/*鍦ㄥ睆骞曚笂杈撳嚭涓€涓嬩俊鎭?/ printf(锛俓n\n\n\n\t\t濮撳悕锛?##锛?锛?printf(锛俓t\t\tSex:#\n锛?; printf(锛俓t\t骞撮緞锛?\n锛?; printf(锛俓n\t\t\t--------瀛︿範缁忓巻--------\n\n\n锛?; printf(锛俓t\t灏忓锛?#####\n\n锛?; printf(锛俓t\t鍒濅腑锛?####\n\n锛?; printf(锛俓t\tS楂樹腑锛?#####\n\n锛?; printf(锛俓t\t澶у锛?#####\n\n锛?; printf(锛俓n\n\t\t鎸変换鎰忛敭杩斿洖娆㈣繋灞忓箷锛侊紓)锛?getch锛?锛?/*鎸変换鎰忛敭杩斿洖涓诲嚱鏁?/}void type锛? /*瀹氫箟閿叆瀛︾敓淇℃伅鍑芥暟*/{ system(锛侰LS锛?; int i锛?/*瀹氫箟灞€閮ㄥ彉閲?/ printf(锛俓t\t杈撳嚭浣犳兂杈撳叆鐨勫鐢熶俊鎭釜鏁帮細锛?锛?scanf(锛?d锛?&n); for(i=0;i { printf(锛俓n\t\t\t----------------\n锛?; printf(锛俓t\t\t瀛﹀彿锛氾紓)锛?scanf(锛?s锛?&stu[i].num)锛?/*杈撳叆瀛﹀彿*/ printf(锛俓t\t\t濮撳悕锛氾紓)锛?scanf(锛?s锛?&stu[i].name)锛?/*杈撳叆濮撳悕*/ printf(锛俓t\t\t鎬у埆锛氾紓)锛?scanf(锛?S锛?&stu[i].sex)锛?/*杈撳叆鎬у埆*/ printf(锛俓t\t\t鑻辫锛氾紓)锛?scanf(锛?d锛?&stu[i].english)锛?/*杈撳叆鑻辫鎴愮哗*/ printf(锛俓t\t\t鏁板锛氾紓)锛?scanf(锛?d锛?&stu[i].math)锛?/*杈撳叆鏁板鎴愮哗*/ printf(锛俓t\t\t璇枃锛氾紓)锛?scanf(锛?d锛?&stu[i].chinese)锛?/*杈撳叆璇枃鎴愮哗*/stu[i].aver=((float)stu[i].english+(float)stu[i].math+(float)stu[i].chinese)/3锛?*璁$畻骞冲潎鎴愮哗*/stu[i].sum=(float)stu[i].english+(float)stu[i].math+(float)stu[i].chinese锛?*璁$畻鎬绘垚缁?/ printf(锛俓t\t\t骞冲潎鎴愮哗=%4.1f\n锛?stu[i].aver)锛?/*杈撳嚭骞冲潎鎴愮哗*/ printf(锛俓t\t\t鎬绘垚缁?%4.1f\n锛?stu[i].sum)锛?/*杈撳嚭鎬绘垚缁?/ } printf(锛俓n\n\t\t\t鎸変换鎰忛敭杩斿洖鑿滃崟锛侊紒锛?锛?getch(); save();}void save锛? /*寤虹珛淇濆瓨鏂囦欢鍑芥暟*/{ system(锛侰LS锛?;FILE *fp锛?/*瀹氫箟鏂囦欢鍨嬫寚閽?/ int i; if((fp=fopen(锛俿tudent.txt锛?锛倃b锛?)==NULL锛?/*鎵撳紑杈撳嚭鏂囦欢*/ { printf锛堬紓涓嶈兘鎵撳紑鏂囦欢锛乗n锛傦級; return锛?/*缁堟绋嬪簭*/ } for(i=0;i if(fwrite(&stu[i],sizeof(struct student),1,fp)!=1) printf锛堬紓鏂囦欢鍐欏叆閿欒\n锛傦級; fclose(fp)锛?/*鍏抽棴鏂囦欢*/ printf(锛俓n\n\n\n\t\t\t瀛︾敓淇℃伅淇濆瓨鎴愬姛锛乗n锛?; printf(锛俓n\n\n\n\t\t\t鎸変换鎰忛敭杩斿洖鑿滃崟锛侊紒锛?锛?getch();}void look锛? /*瀹氫箟鏌ョ湅鍑芥暟*/{ system(锛侰LS锛?; int i; //n=openl锛?锛?/*璋冪敤openl鍑芥暟*/ printf(锛俓t瀛﹀彿\t濮撳悕\t鎬у埆\t鑻辫\t鏁板\t璇枃\t骞冲潎鎴愮哗\t鎬绘垚缁‐n锛?; for(i=0;i { printf(锛?10s\t%s\t%2s\t%d\t%d\t%d\t%3.1f\t\t%6.1f\n锛?stu[i].num,stu[i].name, stu[i].sex,stu[i].english,stu[i].math,stu[i].chinese,stu[i].aver,stu[i].su...

c璇█瀛︾敓绠$悊绯荤粺

C 璇█瀛︾敓鎴愮哗绠$悊绯荤粺 #include #include#include#include typedef struct STUDENT { char studentNumber[20]锛?*瀛︾敓瀛﹀彿*/ char studentName[20]锛?*瀛︾敓濮撳悕*/ char className[20]锛?*鐝骇鍚嶇О*/ float mark1锛?*绗?闂ㄦ垚缁?/ float mark2锛?*绗?闂ㄦ垚缁?/ float mark3锛?*绗?闂ㄦ垚缁?/ struct STUDENT *next; }STUDENT; STUDENT *headLink锛?/*閾捐〃琛ㄥご鎸囬拡*/ /*鍑芥暟澹版槑*/ void ReadInfoFormFile(); void Menu(); void CreateHeadLink(); STUDENT *MallocNode(); void GetInformation(STUDENT *t); void OutputInformation(); void DesplayInfoBystudentName(); void DesplayInfoBystudentNumber(); void DesplayOneNode(STUDENT *t); void InsertOneNode(STUDENT *t); void DeleteNodeBystudentNumber(); void ChangeMarkByName(); void ChangeMarkByNumber(); void SaveLinkToFile();void paixu();void DesplayMarkSegment(); int choose锛?*鐢ㄤ簬鎺ュ彈鐢ㄦ埛鐨勯€夋嫨*/ /*涓诲嚱鏁?/ main() {system(锛俢olor 2a锛?;printf(锛俓n\t\t娆㈣繋杩涘叆***瀛﹂櫌***鐝鐢熸垚缁╃鐞嗙郴缁焅n\n\n锛?;printf(锛俓t\t\t\tO锛堚埄_鈭╋級O\n\n\n\n锛?;printf(锛俓t\t\t^_^\t\t\t^_^\n\n锛?;printf(锛俓n\t\t 娉ㄦ剰锛氳鎸夌収瑕佹眰杈撳叆鐩稿簲淇℃伅锛岃阿璋紒\n\n\n\n\n锛?;printf(锛俓t\t\t\t\t\t\t\t鍒朵綔浜猴細***\n\n\n锛?;printf(锛俓t\t\t 鎸変换鎰忛敭杩涘叆鈥︹€︹€︹€︼紓)锛沢etch();system(锛俢ls锛?;CreateHeadLink();ReadInfoFormFile();Menu锛?锛泒 /*浠庢枃浠朵腑璇诲鐢熶俊鎭埌閾捐〃涓?/ void ReadInfoFormFile(void) { FILE *fp; STUDENT *p; fp=fopen(锛俿tudent.txt锛?锛俽锛?; if(!fp) { printf(锛俓n锛?; return; } p=MallocNode(); while(fscanf(fp,锛?s%s%s%f%f%f锛?p->studentNumber,p->studentName,p->className,&(p->mark1),&(p->mark2),&(p->mark3))>0) { InsertOneNode(p); p=MallocNode(); } fclose(fp)锛?} /*鏄剧ず鑿滃崟锛屾牴鎹敤鎴风殑杈撳叆瀹屾垚鐩稿簲鐨勫姛鑳?/ void Menu(void) { STUDENT *p; printf(锛俓t\t (^o^)娆㈣繋浣跨敤瀛︾敓鎴愮哗绠$悊绯荤粺锛坁o^锛塡n\n锛?;printf(锛俓t 鈥?-------------------璇烽€夋嫨鐩稿簲鍔熻兘---------------------鈥籠n\n锛?; printf(锛俓t 1锛?鏄剧ず鎵€鏈夊鐢熺殑淇℃伅 |锛?锛?printf(锛?\t 2锛?鎸夊鍚嶆煡璇?|\n\n锛?; printf(锛俓t 3锛?鎸夊鍙锋煡璇?|锛?锛?printf(锛?\t\t 4锛?澧炲姞瀛︾敓 |\n\n锛?; printf(锛俓t 5锛?鍒犻櫎瀛︾敓 |锛?锛?printf(锛?\t\t 6锛?鎸夊鍚嶄慨鏀瑰鐢熸垚缁?|\n\n锛?; printf(锛俓t 7锛?鎸夊鍙蜂慨鏀瑰鐢熸垚缁?|锛?锛?printf(锛?\t 8锛?淇濆瓨鎵€鏈夊鐢熶俊鎭?|\n\n锛?; printf(锛俓t 9锛?鎸夋垚缁╄緭鍑哄鐢熶俊鎭?|锛?锛?printf(锛俓t 10锛?鏄剧ず涓嶅強鏍煎強浼樼瀛︾敓 |\n\n锛?;printf(锛俓t 11锛?杩斿洖涓昏彍鍗?|锛?锛?printf(锛俓t\t 12锛?閫€鍑?|\n\n锛?;printf(锛俓t 鈥?---------------------O锛堚埄_鈭╋級O------------------------鈥籠n\n锛?;printf(锛俓t 璇疯緭鍏ュ搴旀暟瀛楋細锛?锛泂canf(锛?d锛?&choose)锛?*鍙栧緱鐢ㄦ埛鐨勯€夋嫨*/ switch(choose) { case 1:system(锛俢ls锛?;OutputInformation锛?锛?*鏄剧ず鎵€鏈夊鐢熺殑淇℃伅*/ break; case 2: system(锛俢ls锛?;DesplayInfoBystudentName(); break; case 3: system(锛俢ls锛?;DesplayInfoBystudentNumber锛?锛?*鏍规嵁鐢ㄦ埛杈撳叆鐨勫鍙锋樉绀鸿瀛︾敓鐨勪俊鎭?/ break; case 4: system(锛俢ls锛?;p=MallocNode锛?锛?*鍏堢敵璇蜂竴涓柊缁撶偣*/ GetInformation(p)锛?*瑕佹眰鐢ㄦ埛杈撳叆淇℃伅鍒版柊缁撶偣涓?/ InsertOneNode(p)锛?*灏嗘柊缁撶偣鍔犲埌閾捐〃涓?/ break; case 5: system(锛俢ls锛?;DeleteNodeBystudentNumber锛?锛?*鏍规嵁鐢ㄦ埛杈撳叆鐨勫鍙峰垹闄よ瀛︾敓*/ break; case 6: system(锛俢ls锛?;ChangeMarkByName锛?锛?*鏍规嵁鐢ㄦ埛杈撳叆鐨勫鍚嶄慨鏀瑰鐢熸垚缁?/ break; case 7: system(锛俢ls锛?;ChangeMarkByNumber锛?锛?*鏍规嵁鐢ㄦ埛杈撳叆鐨勫鍙蜂慨鏀瑰鐢熸垚缁?/ break; case 8: system(锛俢ls锛?;SaveLinkToFile锛?锛?*淇濆瓨鏁版嵁*/ break;case 9: system(锛俢ls锛?;paixu();break;case 10: system(锛俢ls锛?;DesplayMarkSegment();break;case 11: system(锛俢ls锛?;break;case 12: system(锛俢ls锛?;SaveLinkToFile锛?锛?*淇濆瓨鏁版嵁鍚庡啀閫€鍑?/ free(headLink); exit(1); break; default: system(锛俢ls锛?; break;} Menu锛?锛?*閫掑綊璋冪敤*/} /*寤虹珛閾捐〃琛ㄥご*/ void CreateHeadLink(void) {STUDENT *p; p=(STUDENT*)malloc(sizeof(STUDENT)); headLink=p; p->next=NULL锛?} /*鐢宠涓€涓柊缁撶偣锛屽苟灏嗗叾鍒濆鍖?/ STUDENT *MallocNode(void) { STUDENT *p; int i; p=(STUDENT*)malloc(sizeof(STUDENT)); if(p==NULL) return NULL; for(i=0;istudentNumber='\0'; for(i=0;istudentName='\0'; for(i=0;iclassName='\0'; p->mark1=0.0; p->mark2=0.0; p->mark3=0.0; p->next=NULL; return p锛?} /*鍙栧緱鐢ㄦ埛杈撳叆鐨勫鐢熶俊鎭?/ void GetInformation(STUDENT *t) { printf锛堬紓璇疯緭鍏ュ鐢熷鍙凤細锛傦級锛?scanf(锛?s锛?t->studentNumber); printf锛堬紓璇疯緭鍏ュ鐢熷鍚嶏細锛傦級锛?scanf(锛?s锛?t->studentName); printf锛堬紓璇疯緭鍏ヨ鐢熸墍鍦ㄧ彮绾э細锛傦級锛?scanf(锛?s锛?t->className); printf锛堬紓璇疯緭鍏ョ1闂ㄦ垚缁╋細锛傦級锛?scanf(锛?f锛?&(t->mark1)); printf锛堬紓璇疯緭鍏ョ2闂ㄦ垚缁╋細锛傦級锛?scanf(锛?f锛?&(t->mark2)); printf锛堬紓璇疯緭鍏ョ3闂ㄦ垚缁╋細锛傦級锛?scanf(锛?f锛?&(t->mark3)锛夛紱 } /*鍦ㄩ摼琛ㄧ殑缁撳熬澶勫鍔犱竴涓粨鐐?/ void InsertOneNode(STUDENT *t) { STUDENT *p; p=headLink; while(p->next) { p=p->next; } p->next=t锛?} /*鏍规嵁鐢ㄦ埛杈撳叆鐨勫...

鐢╟璇█缂栧啓瀛︾敓淇℃伅绠$悊绯荤粺

鎴戣繖鏈変釜宸笉澶氱殑锛岃鍚楋紵鏄垜鍐欑殑瀹炶浣滀笟 绋嬪簭锛?include #include #include int man=0;int j;char str[20];struct student{ char id[11]; char name[10]; int n1; int n2; int n3; int n4; int n5; int n6; int n7; int n8; int n9; int zong; int ping; }student[100],temp;void read(void){ FILE *cj; int i,k; man=0; while(1) { printf锛堬紓璇疯緭鍏ヨ璇诲彇鐨勬枃浠讹細\n锛傦級; scanf(锛?s锛?&str); if((cj=fopen(str,锛俽锛?)==NULL) { printf锛堬紓鎵撳紑澶辫触\n锛傦級; } else { break; } } for(i=0;i<500;i++) { if(fscanf(cj,锛?s %s %d %d %d %d %d %d %d %d %d锛?&student[i].id,&student[i].name,&student[i].n1,&student[i].n2,&student[i].n3,&student[i].n4,&student[i].n5,&student[i].n6,&student[i].n7,&student[i].n8,&student[i].n9)==-1) { break; } man=man+1; } printf锛堬紓浠?s璇诲彇鍘讳簡鈥?d鈥濇潯璁板綍\n锛?str,man锛? for(k=0;k0;k--) { for(i=0;i0;k--) { for(i=0;i0;k--) { for(i=0;i0;k--) { for(i=0;i0;k--) { for(i=0;i0;k--) { for(i=0;i0;k--) { for(i=0;i0;k--) { for(i=0;i0;k--) { for(i=0;i0;k--) { for(i=0;i<k;i++) { if(student[i].n9<student[i+1].n9) { temp=student[i]; student[i]=student[i+1]; student[i+1]=temp; } } } } else printf锛堬紓鏃犳鍔熻兘\n锛傦級; }void raise(void){ printf锛堬紓璇疯緭鍏ユ坊鍔犱汉鐨勫鍙凤細\n锛傦級; scanf(锛?s锛?&student[man].id); printf锛堬紓璇疯緭鍏ユ坊鍔犱汉鐨勫鍚嶏細\n锛傦級; scanf(锛?s锛?&student[man].name); printf锛堬紓璇疯緭鍏ユ坊鍔犱汉鐨勬垚缁?:\n锛傦級; scanf(锛?d锛?&student[man].n1); printf锛堬紓璇疯緭鍏ユ坊鍔犱汉鐨勬垚缁?:\n锛傦級; scanf(锛?d锛?&student[man].n2); printf锛堬紓璇疯緭鍏ユ坊鍔犱汉鐨勬垚缁?:\n锛傦級; scanf(锛?d锛?&student[man].n3); printf锛堬紓璇疯緭鍏ユ坊鍔犱汉鐨勬垚缁?:\n锛傦級; scanf(锛?d锛?&student[man].n4); printf锛堬紓璇疯緭鍏ユ坊鍔犱汉鐨勬垚缁?:\n锛傦級; scanf(锛?d锛?&student[man].n5); printf锛堬紓璇疯緭鍏ユ坊鍔犱汉鐨勬垚缁?:\n锛傦級; scanf(锛?d锛?&student[man].n6); printf锛堬紓璇疯緭鍏ユ坊鍔犱汉鐨勬垚缁?:\n锛傦級; scanf(锛?d锛?&student[man].n7); printf锛堬紓璇疯緭鍏ユ坊鍔犱汉鐨勬垚缁?:\n锛傦級; scanf(锛?d锛?&student[man].n8); printf锛堬紓璇疯緭鍏ユ坊鍔犱汉鐨勬垚缁?:\n锛傦級; scanf(锛?d锛?&student[man].n9); student[man].zong=student[man].n1+student[man].n2+student[man].n3+student[man].n4+student[man].n5+student[man].n6+student[man].n7+student[man].n8+student[man].n9; student[man].ping=student[man].zong/9; man=man+1;}void alter(void){ int i; char id[10]; printf锛堬紓璇疯緭鍏ヨ淇敼浜虹殑瀛﹀彿锛歕n锛傦級; scanf(锛?s锛?&id); for(i=0;i<man;i++) { if(strcmp(student[i].id,id)==0) { j=i; break; } j=-1; } if(j==-1) { printf锛堬紓鏃犳浜篭n锛傦級; } else { printf锛堬紓璇疯緭鍏ヨ淇敼涓虹殑瀛﹀彿锛歕n锛傦級; scanf(锛?s锛?&student[j].id); printf锛堬紓璇疯緭鍏ヨ淇敼涓虹殑濮撳悕锛歕n锛傦級; scanf(锛?s锛?&student[j].name); printf锛堬紓璇疯緭鍏ヨ淇敼涓虹殑鎴愮哗1:\n锛傦級; scanf(锛?d锛?&student[j].n1); printf锛堬紓璇疯緭鍏ヨ淇敼涓虹殑鎴愮哗2:\n锛傦級; scanf(锛?d锛?&student[j].n2); printf锛堬紓璇疯緭鍏ヨ淇敼涓虹殑鎴愮哗3:\n锛傦級; scanf(锛?d锛?&student[j].n3); printf锛堬紓璇疯緭鍏ヨ淇敼涓虹殑鎴愮哗4:\n锛傦級; scanf(锛?d锛?&student[j].n4); printf锛堬紓璇疯緭鍏ヨ淇敼涓虹殑鎴愮哗5:\n锛傦級; scanf(锛?d锛?&student[j].n5); printf锛堬紓璇疯緭鍏ヨ淇敼涓虹殑鎴愮哗6:\n锛傦級; scanf(锛?d锛?&student[j].n6); printf锛堬紓璇疯緭鍏ヨ淇敼涓虹殑鎴愮哗7:\n锛傦級; scanf(锛?d锛?&student[j].n7); printf锛堬紓璇疯緭鍏ヨ淇敼涓虹殑鎴愮哗8:\n锛傦級; scanf(锛?d锛?&student[j].n8); printf锛堬紓璇疯緭鍏ヨ淇敼涓虹殑鎴愮哗9:\n锛傦級; scanf(锛?d锛?&student[j].n9); student[j].zong=student[j].n1+student[j].n2+student[j].n3+student[j].n4+student[j].n5+student[j].n6+student[j].n7+student[j].n8+student[j].n9; student[j].ping=student[j].zong/9; }}void deletes(){ int i,k; char id[10]; printf锛堬紓璇疯緭鍏ヨ鍒犻櫎浜虹殑瀛﹀彿锛歕n锛傦級; scanf(锛?s锛?&id); for(i=0;i<man;i++) { if(strcmp(student[i].id,id)==0) { j=i; break; } j=-1; } if(j==-1) { printf锛堬紓鏃犳浜篭n锛傦級; } else { for(k=j;k<man;k++) { student[j]=student[j+1]; j=j+1; } man=man-1; }}void menu(void){ int i; printf(锛俓n锛?; for(i=0;i<10;i++) printf(锛?锛?; for(i=0;i<60;i++) printf(锛?锛?; for(i=0;i<9;i++) printf(锛?锛?; printf(锛俓n锛?; for(i=0;i<10;i++) printf(锛?锛?; printf(锛? 1.鏄剧ず瀛︾敓鎴愮哗淇℃伅 6.鏌ヨ涓嶅強鏍煎鐢熶俊鎭?#\n锛?; for(i=0;i<10;i++) printf(锛?锛?; printf(锛? 2.鎸夋垚缁╃敱楂樺埌浣庢帓搴?7.淇敼瀛︾敓鎴愮哗淇℃伅 #\n锛?; for(i=0;i<10;i++) printf(锛?锛?; printf(锛? 3.娣诲姞瀛︾敓鎴愮哗淇℃伅 8.璇诲彇鏂囦欢 #\n锛?; for(i=0;i<10;i++) printf(锛?锛?; printf(锛? 4.鍒犻櫎瀛︾敓鎴愮哗淇℃伅 9.淇濆瓨鏂囦欢 #\n锛?; for(i=0;i<10;i++) printf(锛?锛?; printf(锛? 5.鏌ヨ瀛︾敓鎴愮哗淇℃伅 -. 鍙﹀瓨涓?#\n锛?; for(i=0;i<10;i++) printf(锛?锛?; printf锛堬紓# +.閫€鍑?#\n锛傦級; for(i=0;i<10;i++) printf(锛?锛?; for(i=0;i<60;i++) printf(锛?锛?; for(i=0;i<9;i++) printf(锛?锛?; printf(锛俓n锛?;}int main(void){ char i; read(); menu(); while(1) { printf锛堬紓璇疯緭鍏ヨ閫夋嫨鐨勯渶瑕佸姛鑳界殑搴忓垪鍙凤紙杈撳叆0鏄剧ず鑿滃崟锛夛細\n锛?; scanf(锛?s锛?&i); if(i=='1') { print(); } else if(i=='2') { compositor(); print(); } else if(i=='3') { raise(); print(); } else if(i=='4') { deletes(); print(); } else if(i=='5') { inquiry(); } else if(i=='6') { fail(); } else if(i=='7') { alter(); print(...

C璇█瀛︾敓淇℃伅绠$悊绯荤粺璁捐

[姝ら棶棰樼殑鎺ㄨ崘绛旀]#include 锛俿tdio.h锛?#include 锛俿tdlib.h锛?#include 锛俿tring.h锛?int shoudsave=0; /* */ struct student { char num[10]锛?* 瀛﹀彿 */ char name[20]; char sex[4]; int age; int birth; int tele; char addr[30]; }; typedef struct node { struct student data; struct node *next; }Node,*Link; /*************************************************************************************/ void menu() { printf(锛?*******************************************************************************锛?; printf(锛俓t1鐧昏瀛︾敓璧勬枡\t\t\t\t\t2鍒犻櫎瀛︾敓璧勬枡\n锛?; printf(锛俓t3鏌ヨ瀛︾敓璧勬枡\t\t\t\t\t4淇敼瀛︾敓璧勬枡\n锛?; printf(锛俓t5淇濆瓨瀛︾敓璧勬枡\t\t\t\t\t0閫€鍑虹郴缁焅n锛?; printf(锛?*******************************************************************************\n锛?; } /*************************************************************************************/ void printstart() { printf(锛?----------------------------------------------------------------------\n锛?; } void Wrong() { printf(锛俓n=====>鎻愮ず锛氳緭鍏ラ敊璇紒\n锛?; } void Nofind() { printf(锛俓n=====>鎻愮ず锛氭病鏈夋壘鍒拌瀛︾敓锛乗n锛?; } void printc锛? /* 鏈嚱鏁扮敤浜庤緭鍑轰腑鏂?*/ { printf锛堬紓 瀛﹀彿\t 濮撳悕 鎬у埆 \t 鐢佃瘽 \t 鍑虹敓骞存湀\t 骞撮緞\t 鍦板潃\n锛傦級; } /*************************************************************************************/ void printe(Node *p)/* 鏈嚱鏁扮敤浜庤緭鍑鸿嫳鏂?*/ { printf(锛?-12s%s\t%s\t%d\t%d\t%d\t%s \n锛?p->data.num,p->data.name,p->data.sex,p->data.tele,p->data.birth,p->data.age,p->data.addr); } Node* Locate(Link l,char findmess[],char nameornum[]) /* 璇ュ嚱鏁扮敤浜庡畾浣嶈繛琛ㄤ腑绗﹀悎瑕佹眰鐨勬帴鐐癸紝骞惰繑鍥炶鎸囬拡 */ { Node *r; if(strcmp(nameornum,锛俷um锛?==0锛?/* 鎸夊鍙锋煡璇?*/ { r=l->next; while(r!=NULL) { if(strcmp(r->data.num,findmess)==0) return r; r=r->next; } } else if(strcmp(nameornum,锛俷ame锛?==0锛?/* 鎸夊鍚嶆煡璇?*/ { r=l->next; while(r!=NULL) { if(strcmp(r->data.name,findmess)==0) return r; r=r->next; } } return 0; } /*************************************************************************************/ void Add(Link l) /* 澧炲姞瀛︾敓 */ { Node *p,*r,*s; char num[10]; r=l; s=l->next; while(r->next!=NULL) r=r->next锛?/* 灏嗘寚閽堢疆浜庢渶鏈熬 */ while(1) { printf锛堬紓璇蜂綘杈撳叆瀛﹀彿锛堜互'0'杩斿洖涓婁竴绾ц彍鍗曪紓锛夛紱 scanf(锛?s锛?num); if(strcmp(num,锛?锛?==0) break; while(s) { if(strcmp(s->data.num,num)==0) { printf锛堬紓=====>鎻愮ず锛氬鍙蜂负'%s'鐨勫鐢熷凡缁忓瓨鍦紝鑻ヨ淇敼璇蜂綘閫夋嫨'4 淇敼'锛乗n锛?num锛? printstart(); printc(); printe(s); printstart(); printf(锛俓n锛?; return; } s=s->next; } p=(Node *)malloc(sizeof(Node)); strcpy(p->data.num,num); printf锛堬紓璇蜂綘杈撳叆濮撳悕锛氾紓锛夛紱 scanf(锛?s锛?p->data.name); getchar(); printf锛堬紓璇蜂綘杈撳叆鎬у埆锛氾紓锛夛紱 scanf(锛?s锛?p->data.sex); getchar(); printf锛堬紓璇蜂綘杈撳叆骞撮緞锛氾紓锛夛紱 scanf(锛?d锛?&p->data.age); getchar(); printf锛堬紓璇蜂綘杈撳叆鍑虹敓骞存湀锛氾紓锛夛紱 scanf(锛?d锛?&p->data.birth); getchar(); printf锛堬紓璇蜂綘杈撳叆鐢佃瘽锛氾紓锛夛紱 scanf(锛?d锛?&p->data.tele); getchar(); printf锛堬紓璇疯緭鍏ュ湴鍧€锛氾紓锛夛紱 scanf(锛?s锛?&p->data.addr); getchar锛?锛?/* 淇℃伅杈撳叆宸茬粡瀹屾垚 */ p->next=NULL; r->next=p; r=p; shoudsave=1; } } /*************************************************************************************/ void Qur(Link l) /* 鏌ヨ瀛︾敓 */ { int sel; char findmess[20]; Node *p; if(!l->next) { printf(锛俓n=====>鎻愮ず锛氭病鏈夎祫鏂欏彲浠ユ煡璇紒\n锛?; return; } printf(锛俓n=====>1鎸夊鍙锋煡鎵綷n=====>2鎸夊鍚嶆煡鎵綷n锛?; scanf(锛?d锛?&sel); if(sel==1)/* 瀛﹀彿 */ { printf锛堬紓璇蜂綘杈撳叆瑕佹煡鎵剧殑瀛﹀彿锛氾紓锛夛紱 scanf(锛?s锛?findmess); p=Locate(l,findmess,锛俷um锛?; if(p) { printf(锛俓t\t\t\t鏌ユ壘缁撴灉\n锛?; printstart(); printc(); printe(p); printstart(); } else Nofind(); } else if(sel==2) /* 濮撳悕 */ { printf锛堬紓璇蜂綘杈撳叆瑕佹煡鎵剧殑濮撳悕锛氾紓锛夛紱 scanf(锛?s锛?findmess); p=Locate(l,findmess,锛俷ame锛?; if(p) { printf(锛俓t\t\t\t鏌ユ壘缁撴灉\n锛?; printstart(); printc(); printe(p); printstart(); } else Nofind(); } else Wrong(); } /*************************************************************************************/ void Del(Link l) /* 鍒犻櫎 */ { int sel; Node *p,*r; char findmess[20]; if(!l->next) { printf(锛俓n=====>鎻愮ず锛氭病鏈夎祫鏂欏彲浠ュ垹闄わ紒\n锛?; return; } printf(锛俓n=====>1鎸夊鍙峰垹闄n=====>2鎸夊鍚嶅垹闄n锛?; scanf(锛?d锛?&sel); if(sel==1) { printf锛堬紓璇蜂綘杈撳叆瑕佸垹闄ょ殑瀛﹀彿锛氾紓锛夛紱 scanf(锛?s锛?findmess); p=Locate(l,findmess,锛俷um锛?; if(p) { r=l; while(r->next!=p) r=r->next; r->next=p->next; free(p); printf(锛俓n=====>鎻愮ず锛氳瀛︾敓宸茬粡鎴愬姛鍒犻櫎锛乗n锛?; shoudsave=1; } else Nofind(); } else if(sel==2) { printf锛堬紓璇蜂綘杈撳叆瑕佸垹闄ょ殑濮撳悕锛氾紓锛夛紱 scanf(锛?s锛?findmess); p=Locate(l,findmess,锛俷ame锛?; if(p) { r=l; while(r->next!=p) r=r->next; r->next=p->next; free(p); printf(锛俓n=====>鎻愮ず锛氳瀛︾敓宸茬粡鎴愬姛鍒犻櫎锛乗n锛?; shoudsave=1; } else Nofind(); } else Wrong(); } /*************************************************************************************/ void Modify(Link l) { Node *p; char findmess[20]; if(!l->next) { printf(锛俓n=====>鎻愮ず锛氭病鏈夎祫鏂欏彲...

c璇█瀛︾敓淇℃伅绠$悊绯荤粺浠g爜

#include#include#includevoid frist_print(){ printf(锛俓t\t********************************\n\n锛?锛?//娆㈣繋淇℃伅 printf(锛俓t\t\t娆㈣繋杩涘叆瀛︾敓鎴愮哗绯荤粺\n锛?;}void menu() { printf(锛俓n\t\t********************************\n锛?锛?//绠$悊鑿滃崟 printf(锛俓t\t==\t1.褰曞叆瀛︾敓鎴愮哗\n\t\t+\n锛?; printf(锛俓t\t==\t2.鏄剧ず瀛︾敓鎴愮哗\n\t\t+\n锛?; printf(锛俓t\t==\t3.鏌ヨ瀛︾敓鎴愮哗\n\t\t+\n锛?; printf(锛俓t\t==\t4.娣诲姞瀛︾敓鎴愮哗\n\t\t+\n锛?; printf(锛俓t\t==\t5.淇敼瀛︾敓鎴愮哗\n\t\t+\n锛?; printf(锛俓t\t==\t6.鍒犻櫎瀛︾敓鎴愮哗\n\t\t+\n锛?; printf(锛俓t\t==\t7.娓呯┖椤甸潰\n\t\t+\n锛?; printf(锛俓t\t==\t8.閫€鍑虹郴缁焅n锛?; printf(锛俓t\t********************************\n锛?; printf(锛俻lease choise 1--8:\t锛?; putchar(10); }struct MM // 缁撴瀯浣撳畾涔夊彉閲? { char num[20]; char name[10]; float pay; int many; }mm;void scanf_1锛? //绗竴娆¤緭鍏ヤ俊鎭苟淇濆瓨鍦ㄦ枃浠朵腑 { char ch; FILE *fp; if((fp=fopen(锛俤d.dat锛?锛倃b+锛?)==NULL) { printf(锛俢annot open file\n锛?; exit(0); } do { printf锛堬紓璇疯緭鍏ユ垚缁╃殑--缂栧彿锛歕t锛傦級; getchar(); gets(mm.num); printf锛堬紓濮撳悕锛歕t锛傦級; gets(mm.name); printf锛堬紓鎴愮哗锛歕t锛傦級; scanf(锛?f锛?&mm.pay); printf锛堬紓瀛﹀彿锛歕t锛傦級; scanf(锛?d锛?&mm.many); if(fwrite(&mm,sizeof(struct MM),1,fp)!=1) { printf(锛俧ile write error\n锛?; exit(0); } printf锛堬紓鏄惁缁х画杈撳叆y or n ?\t锛傦級; getchar(); ch=getchar(); }while(ch=='y'||ch=='Y'); fclose(fp); }void find锛? //鏌ヨ鎴愮哗鐨勪俊鎭?{ int a,b=0; char ch[20]; FILE *fp; if((fp=fopen(锛俤d.dat锛?锛俽b锛?)==NULL) { printf(锛俢annot open file\n锛?; exit(0); } printf锛堬紓璇疯緭鍏ヨ鏌ヨ鐨勬垚缁╃殑鏂瑰紡\n\t1.缂栧彿 2.濮撳悕锛歕n\t璇烽€夋嫨 1 or 2 \t锛傦級; scanf(锛?d锛?&a); if(a==1) { getchar(); printf锛堬紓璇疯緭鍏ユ垚缁╃殑缂栧彿锛歕t锛傦級; gets(ch); while(fread(&mm,sizeof(struct MM),1,fp)==1) if(strcmp(mm.num,ch)==0) { b++; printf锛堬紓缂栧彿\t濮撳悕\t浠锋牸\t\t瀛﹀彿\n锛傦級; printf(锛?s\t%s\t%.3f\t\t%d\n锛?mm.num,mm.name,mm.pay,mm.many); } if(b==0) printf锛堬紓瀵逛笉璧凤紒娌℃湁鎵惧埌鐩稿叧淇℃伅锛歕n锛傦級; } else if(a==2) { printf锛堬紓璇疯緭鍏ユ垚缁╃殑濮撳悕锛歕t锛傦級; getchar(); gets(ch); while(fread(&mm,sizeof(struct MM),1,fp)==1) if(strcmp(mm.name,ch)==0) { b++; printf锛堬紓缂栧彿\t濮撳悕\t浠锋牸\t\t瀛﹀彿\n锛傦級; printf(锛?s\t%s\t%.3f\t\t%d\n锛?mm.num,mm.name,mm.pay,mm.many); } if(b==0) printf(锛俰nput error!\n锛?; } fclose(fp); } void scanf_2锛? //绗簩娆¤緭鍏ヤ俊鎭苟淇濆瓨鍦ㄦ枃浠朵腑 { char ch; FILE *fp; if((fp=fopen(锛俤d.dat锛?锛俛b锛?)==NULL) { printf(锛俢annot open file\n锛?; exit(0); } do { printf锛堬紓璇疯緭鍏ヨ娣诲姞鎴愮哗鐨?-缂栧彿锛歕t锛傦級; getchar(); gets(mm.num); printf锛堬紓濮撳悕锛歕t锛傦級; gets(mm.name); printf锛堬紓浠锋牸锛歕t锛傦級; scanf(锛?f锛?&mm.pay); printf锛堬紓瀛﹀彿锛歕t锛傦級; scanf(锛?d锛?&mm.many); if(fwrite(&mm,sizeof(struct MM),1,fp)!=1) { printf(锛俧ile write error\n锛?; exit(0); } printf锛堬紓鏄惁缁х画杈撳叆y or n ?\t锛傦級; getchar(); ch=getchar(); }while(ch=='y'||ch=='Y'); fclose(fp); } void print锛? //杈撳嚭鏂囨。涓殑淇℃伅 { FILE *fp; if((fp=fopen(锛俤d.dat锛?锛俽b锛?)==NULL) { printf(锛俢annot open file\n锛?; return ; } printf锛堬紓缂栧彿\t濮撳悕\t浠锋牸\t\t瀛﹀彿\n锛傦級; while(fread(&mm,sizeof(struct MM),1,fp)==1) printf(锛?s\t%s\t%.3f\t\t%d\n锛?mm.num,mm.name,mm.pay,mm.many); fclose(fp); }void change锛?{ //淇敼淇℃伅鐨勫嚱鏁帮紝瀹氫箟鍙︿竴涓枃浠讹紝鎶婅淇敼鐨勪俊鎭斁鍒拌鏂囦欢涓? struct XX //鐒跺悗鎶婂叾浣欑殑淇℃伅澶嶅埗鍒拌鏂囦欢涓紱骞舵妸璇ユ枃浠朵粠鏂板懡鍚嶄负鍘熸潵鐨勫悕 { //鎶婂師鏉ョ殑鏂囦欢绉婚櫎锛? char num[20]; char name[10]; float pay; int many; }xx; FILE *fp2; int a,b=0,c=0,n=0; char ch[20],ck; FILE *fp; do{ if((fp=fopen(锛俤d.dat锛?锛俽b锛?)==NULL) { printf(锛俢annot open file\n锛?; exit(0); } if((fp2=fopen(锛倀emp.dat锛?锛倃b锛?)==NULL) { printf(锛俢annot open file\n锛?; exit(0); } printf锛堬紓璇疯緭鍏ヨ淇敼鎴愮哗鐨勭紪鍙凤細\t锛傦級; scanf(锛?s锛?ch); n++; while(fread(&mm,sizeof(struct MM),1,fp)==1) { if((strcmp(mm.num,ch)==0)) { b++; //b鐨勫€煎鏋滀竴鐩存病鏈夋敼鍙樿鏄庯紝娌℃湁鎵惧埌鐩稿叧鐨勪俊鎭紱 printf锛堬紓缂栧彿\t濮撳悕\t浠锋牸\t\t瀛﹀彿\n锛傦級; printf(锛?s\t%s\t%.3f\t\t%d\n锛?mm.num,mm.name,mm.pay,mm.many); getchar(); printf锛堬紓璇疯緭鍏ユ垚缁╃殑鏂扮紪鍙凤細\t锛傦級; gets(xx.num); printf锛堬紓璇疯緭鍏ユ垚缁╃殑鏂板鍚嶏細\t锛傦級; gets(xx.name); printf锛堬紓璇疯緭鍏ユ垚缁╃殑鏂颁环鏍硷細\t锛傦級; scanf(锛?f锛?&xx.pay); printf锛堬紓璇疯緭鍏ユ垚缁╂柊瀛﹀彿锛歕t锛傦級; scanf(锛?d锛?&xx.many); getchar(); fwrite(&xx,sizeof(struct XX),1,fp2); } if(strcmp(mm.num,ch)!=0) fwrite(&mm,sizeof(struct MM),1,fp2); } if(b==0) { printf(锛俓t娌℃湁鎵惧埌鐩稿叧淇℃伅锛乗n锛?; getchar(); } rewind(fp)锛?//濡傛灉瑕佺户缁慨鏀圭殑璇濓紝瑕佹妸鏍囪杩斿洖鍒版枃浠剁殑寮€澶达紱 printf锛堬紓鏄惁缁х画淇敼锛焑nter 'y' or 'n' \t锛傦級; ck=getchar(); fclose(fp); fclose(fp2); remove(锛俤d.dat锛?; rename(锛倀emp.dat锛?锛俤d.dat锛?; }while(ck=='y'||ck=='Y'); if(b!=0) //濡傛灉娌℃湁鎵惧埌鐩稿叧淇℃伅灏变笉鑳借緭鍑? printf(锛俓t淇敼鎴愬姛锛歕n锛?;}void del锛?{ //鍒犻櫎鍑芥暟鍜屼慨鏀瑰緢鐩镐技 FILE *fp2; int a,b=0,c=0,n=0; char ch[20],ck; FILE *fp; do { if((fp=fopen(锛俤d.dat锛?锛俽b锛?)==NULL) { printf(锛俢annot open file\n锛?; exit(0); } if((fp2=f...

C璇█瀛︾敓绠$悊绯荤粺

#include #include #include #include #define max 20 typedef struct student //瀛︾敓 { char sno[max]锛?// 瀛﹀彿 char sname[max]锛?//濮撳悕 char sex[max]锛?//鎬у埆 char age[max]锛?//骞撮緞 char depart[max]锛?//绯?char classs[max]锛?//鐝?char grade[max]锛?//骞寸骇 struct student* next; } student; student* head; int LogOn锛? //鐧诲綍妯″潡锛屽凡瀹炵幇杈撳叆瀵嗙爜涓嶅洖鏄撅紝濡傛灉涓€斿彂鐜拌緭閿欐煇鍑犱綅锛屽彲閫€鏍奸敭閲嶈緭 { char username[max],password[max]; printf(锛俓n璇疯緭鍏ョ敤鎴峰悕锛氾紓)锛?scanf(锛?s锛?username); printf(锛俓n璇疯緭鍏ュ瘑鐮侊紙鏈€澶?5浣嶏級锛氾紓锛夛紱 //寮€濮嬩互涓嶅洖鏄句笖鏀寔閫€鏍兼柟寮忚幏鍙栬緭鍏ュ瘑鐮?int i=0; while((i>=0)&&(password[i++]=getch())!=13锛?/鏉′欢i>=0鏄敤浜庨檺鍒堕€€鏍肩殑鑼冨洿 { if(password[i-1]=='\b')//瀵归€€鏍奸敭鐨勫鐞?{ printf(锛?c%c%c锛?'\b','\0','\b'); i=i-2; } else printf(锛?锛?; } password[--i]='\0'锛?//宸茶幏鍙栧瘑鐮併€?/p>

楠岃瘉鐢ㄦ埛韬唤 if(!strcmp(username,锛倆hang锛?&&!strcmp(password,锛?147086锛?) { printf(锛俓n鐧诲綍鎴愬姛锛侊紓)锛?return 1; } else return 0; } void regist() { char ch; student *s,*ptr; //s鐢ㄦ潵寤烘柊缁撶偣锛宲tr鐢ㄦ潵鏆傚瓨澶寸粨鐐?do { s=(student*)malloc(sizeof(student)锛夛紱 // 鏂板缓涓€涓鐢熺粨鐐?printf(锛俓n寮€濮嬫敞鍐?..锛?锛?//寮€濮嬫敞鍐? printf(锛俓n璇疯緭鍏ヨ瀛︾敓鐨勫鍙凤細锛?锛? scanf(锛?s锛?s->sno); printf(锛俓n璇疯緭鍏ヨ瀛︾敓鐨勫鍚嶏細锛?锛? scanf(锛?s锛?s->sname); printf(锛俓n璇疯緭鍏ヨ瀛︾敓鐨勬€у埆锛氾紓)锛? scanf(锛?s锛?s->sex); printf(锛俓n璇疯緭鍏ヨ瀛︾敓鐨勫勾榫勶細锛?锛? scanf(锛?s锛?s->age); printf(锛俓n璇疯緭鍏ヨ瀛︾敓鐨勭郴锛氾紓)锛? scanf(锛?s锛?s->depart); printf(锛俓n璇疯緭鍏ヨ瀛︾敓鎵€鍦ㄧ殑鐝細锛?锛? scanf(锛?s锛?s->classs); printf(锛俓n璇疯緭鍏ヨ瀛︾敓鎵€鍦ㄧ殑骞寸骇锛?锛? scanf(锛?s锛?s->grade); ptr=head; head=s锛?/灏嗘柊缁撶偣鎻掑叆闃熷ご s->next=ptr; fflush(stdin); printf(锛俓n璇烽棶鏄惁缁х画娉ㄥ唽锛燂紙Y/N锛夛紓); scanf(锛?c锛?&ch); }while(ch=='Y'||ch=='y'); return; } void ElePrint(char str[]) //杈撳嚭鍗曚釜鍏冪礌 { if(str==NULL) exit(0); printf(锛?s锛?str); for(unsigned int i=0;isno); ElePrint(ptr->sname); ElePrint(ptr->age); ElePrint(ptr->sex); ElePrint(ptr->depart); ElePrint(ptr->classs); ElePrint(ptr->grade); return 1; } void print锛? //杈撳嚭鍏ㄩ儴瀛︾敓淇℃伅 { student *ptr=head; printf(锛俓n瀛﹀彿 濮撳悕 骞撮緞 鎬у埆 绯?鐝?骞寸骇 锛?锛?while(ptr) { LinePrint(ptr); ptr=ptr->next; } printf(锛俓n锛?; return; } void search锛?//鏌ヨ妯″潡 { int method锛?/鏌ヨ鏂瑰紡 char no[max],name[max],departm[max],clss[max],grades[max]锛?//鐢ㄦ潵鎺ユ敹鏌ヨ鍏抽敭瀛?while(1) { printf(锛俓n璇烽€夋嫨鏌ヨ鏂瑰紡锛?锛? printf(锛俓n1.鎸夊鍙锋煡璇紓)锛? printf(锛俓n2.鎸夊鍚嶆煡璇紓)锛? printf(锛俓n3.鎸夋墍鍦ㄧ郴鏌ヨ锛?锛? printf(锛俓n4.鎸夋墍鍦ㄧ彮绾ф煡璇紓)锛? printf(锛俓n5.鎸夋墍鍦ㄥ勾绾ф煡璇紓)锛?printf(锛俓n6.鎵撳嵃鍏ㄩ儴瀛︾敓淇℃伅锛?锛? printf(锛俓n7.杩斿洖涓昏彍鍗昞n锛?; scanf(锛?d锛?&method); student *p=head,*temp; switch(method) { case 1: printf(锛俓n璇疯緭鍏ヨ鏌ヨ鐨勫鍙凤細锛?锛? scanf(锛?s锛?no); while(p) { if(!strcmp(p->sno,no)) break; else { temp=p; p=p->next; } } printf(锛俓n瀛﹀彿 濮撳悕 骞撮緞 鎬у埆 绯?鐝?骞寸骇 锛?锛? LinePrint(p); break; case 2: printf(锛俓n璇疯緭鍏ヨ鏌ヨ鐨勫鍚嶏細锛?锛? scanf(锛?s锛?name); printf(锛俓n瀛﹀彿 濮撳悕 骞撮緞 鎬у埆 绯?鐝?骞寸骇 锛?锛? while(p) { if(!strcmp(p->sname,name)) LinePrint(p); p=p->next; } break; case 3: printf(锛俓n璇疯緭鍏ュ鐢熸墍鍦ㄧ殑绯伙細锛?锛? scanf(锛?s锛?departm); printf(锛俓n瀛﹀彿 濮撳悕 骞撮緞 鎬у埆 绯?鐝?骞寸骇 锛?锛? while(p) { if(!strcmp(p->depart,departm)) LinePrint(p); p=p->next; } break; case 4: printf(锛俓n璇疯緭鍏ュ鐢熸墍鍦ㄧ殑鐝細锛?锛? scanf(锛?s锛?clss); printf(锛俓n璇疯緭鍏ュ鐢熸墍鍦ㄧ殑骞寸骇锛氾紓)锛? scanf(锛?s锛?grades); printf(锛俓n瀛﹀彿 濮撳悕 骞撮緞 鎬у埆 绯?鐝?骞寸骇 锛?锛? while(p) { if(!strcmp(p->classs,clss)&&!strcmp(p->grade,grades)) LinePrint(p); p=p->next; } break; case 5: printf(锛俓n璇疯緭鍏ュ鐢熸墍鍦ㄧ殑骞寸骇锛氾紓)锛? scanf(锛?s锛?grades); printf(锛俓n瀛﹀彿 濮撳悕 骞撮緞 鎬у埆 绯?鐝?骞寸骇 锛?锛? while(p) { if(!strcmp(p->grade,grades)) LinePrint(p); p=p->next; } break; case 6: print(); break; case 7: return; default: printf锛堬紓寰堟姳姝夛紝鏆傛棤姝ゆ煡璇㈡柟寮忥紒锛傦級锛? break; } } } void modify锛?//淇敼瀛︾敓淇℃伅 { char num[max]; student *p=head; printf(锛俓n璇疯緭鍏ヨ淇敼鐨勫鐢熺殑瀛﹀彿锛氾紓)锛?scanf(锛?s锛?num); while(p) { if(!strcmp(p->sno,num)) break; else p=p->next; } if(p==NULL) { printf(锛俓n閿欒锛?..

瀛︾敓淇℃伅绠$悊绯荤粺C璇█缂栫▼

#include /*I/O鍑芥暟*/#include /*鍏跺畠璇存槑*/#include /*瀛楃涓插嚱鏁?/#define BUFLEN 100 /* 缂撳啿鍖烘渶澶у瓧绗︽暟 */#define LEN 15 /* 瀛﹀彿鍜屽鍚嶆渶澶у瓧绗︽暟锛屽疄闄呰鏇存敼 */#define N 100 /* 鏈€澶у鐢熶汉鏁帮紝瀹為檯璇锋洿鏀?/struct record /*缁撴瀯浣?/{char code[LEN+1]锛?/* 瀛﹀彿 */char name[LEN+1]锛?/* 濮撳悕 */int age锛?/* 骞撮緞 */char sex[3]锛?/* 鎬у埆 */char time[LEN+1]锛?/* 鍑虹敓骞存湀 */char add[30]锛?/* 瀹跺涵鍦板潃 */char tel[LEN+1]锛?/* 鐢佃瘽鍙风爜 */char mail[30]锛?/* 鐢靛瓙閭欢鍦板潃 */}stu[N];int k=1,n,m锛?/* 瀹氫箟鍏ㄥ眬鍙橀噺 */ void readfile锛?锛?* 鍑芥暟澹版槑 */void seek();void modify();void insert();void del();void display();void save();void menu(); int main(){ while(k)menu();system(锛俻ause锛?;return 0;} void help(){ printf(锛俓n0.娆㈣繋浣跨敤绯荤粺甯姪锛乗n锛?;printf(锛俓n1.杩涘叆绯荤粺鍚庯紝鍏堝埛鏂板鐢熶俊鎭紝鍐嶆煡璇紱\n锛?;printf(锛俓n2.鎸夌収鑿滃崟鎻愮ず閿叆鏁板瓧浠e彿锛沑n锛?;printf(锛俓n3.澧炲姞瀛︾敓淇℃伅鍚庯紝鍒囪淇濆瓨鎸?;\n锛?;printf(锛俓n4.璋㈣阿鎮ㄧ殑浣跨敤锛乗n锛?;} void readfile锛?/* 寤虹珛淇℃伅 */{char *p=锛俿tudent.txt锛?FILE *fp;int i=0;if ((fp=fopen(锛俿tudent.txt锛?锛俽锛?)==NULL){ printf(锛侽pen file %s error! Strike any key to exit!锛?p);system(锛俻ause锛?;exit(0);}while(fscanf(fp,锛?s %s%d%s %s %s %s %s锛?stu[i].code,stu[i].name,&stu[i].age,stu[i].sex,stu[i].time,stu[i].add,stu[i].tel,stu[i].mail)==8){i++;i=i;}fclose(fp);n=i;printf锛堬紓褰曞叆瀹屾瘯锛乗n锛傦級;} void seek锛? /*鏌ユ壘*/{int i,item,flag;char s1[21]锛?/* 浠ュ鍚嶅拰瀛﹀彿鏈€闀块暱搴?1涓哄噯 */printf(锛?-----------------\n锛?;printf(锛?----1.鎸夊鍙锋煡璇?----\n锛?;printf(锛?----2.鎸夊鍚嶆煡璇?----\n锛?;printf(锛?----3.閫€鍑烘湰鑿滃崟-----\n锛?;printf(锛?-----------------\n锛?;while(1){printf锛堬紓璇烽€夋嫨瀛愯彍鍗曠紪鍙凤細锛傦級锛泂canf(锛?d锛?&item);flag=0;switch(item){case 1:printf锛堬紓璇疯緭鍏ヨ鏌ヨ鐨勫鐢熺殑瀛﹀彿锛歕n锛傦級;scanf(锛?s锛?s1);for(i=0;ii;j--)if(strcmp(stu[j-1].code,stu[j].code)>0){strcpy(temp,stu[j-1].code);strcpy(stu[j-1].code,stu[j].code);strcpy(stu[j].code,temp);strcpy(temp,stu[j-1].name);strcpy(stu[j-1].name,stu[j].name);strcpy(stu[j].name,temp);strcpy(temp,stu[j-1].sex);strcpy(stu[j-1].sex,stu[j].sex);strcpy(stu[j].sex,temp);strcpy(temp,stu[j-1].time);strcpy(stu[j-1].ti...

濡備綍鐢–璇█缂栧啓瀛︾敓淇℃伅绠$悊绯荤粺

鍙傝€冨涓嬪鐢熶俊鎭鐞嗙郴缁熺殑C婧愪唬鐮佸惂銆?/p>

#include #include /*瀹氫箟瀛︾敓缁撴瀯浣?/struct Student{ char ID[20]; char Name[20]; float Mark1; float Mark2; float Mark3; float Average锛泒锛?*澹版槑瀛︾敓鏁扮粍鍙婂鐢熸暟閲?/struct Student students[1000];int num=0锛?*姹傚钩鍧囧€?/float Avg(struct Student stu){ return (stu.Mark1+stu.Mark2+stu.Mark3)/3锛泒/*閫氳繃瀛﹀彿杩斿洖鏁扮粍涓嬫爣*/int Student_SearchByIndex(char id[]){ int i; for (i=0;i { if (strcmp(students[i].ID,id)==0) { return i; } } return -1锛泒/*閫氳繃濮撳悕杩斿洖鏁扮粍涓嬫爣*/int Student_SearchByName(char name[]){ int i; for (i=0;i { if (strcmp(students[i].Name,name)==0) { return i; } } return -1锛泒/*鏄剧ず鍗曟潯瀛︾敓璁板綍*/void Student_DisplaySingle(int index){ printf(锛?10s%10s%8s%8s%8s%10s\n锛傦紝锛傚鍙凤紓锛岋紓濮撳悕锛傦紝锛傛垚缁╋紓锛岋紓鎴愮哗锛傦紝锛傛垚缁╋紓锛岋紓骞冲潎鎴愮哗锛?锛?printf(锛?------------------------------------------------------------\n锛?; printf(锛?10s%10s%8.2f%8.2f%8.2f%10.2f\n锛?students[index].ID,students[index].Name, students[index].Mark1,students[index].Mark2,students[index].Mark3,students[index].Average)锛泒/*鎻掑叆瀛︾敓淇℃伅*/void Student_Insert(){ while(1) { printf锛堬紓璇疯緭鍏ュ鍙凤細锛傦級锛?scanf(锛?s锛?&students[num].ID); getchar(); printf锛堬紓璇疯緭鍏ュ鍚嶏細锛傦級锛?scanf(锛?s锛?&students[num].Name); getchar(); printf锛堬紓璇疯緭鍏ユ垚缁╋細锛傦級锛?scanf(锛?f锛?&students[num].Mark1); getchar(); printf锛堬紓璇疯緭鍏ユ垚缁╋細锛傦級锛?scanf(锛?f锛?&students[num].Mark2); getchar(); printf锛堬紓璇疯緭鍏ユ垚缁╋細锛傦級锛?scanf(锛?f锛?&students[num].Mark3); getchar(); students[num].Average=Avg(students[num]); num++; printf锛堬紓鏄惁缁х画锛燂紙y/n锛夛紓); if (getchar()=='n') { break锛?} }}/*淇敼瀛︾敓淇℃伅*/void Student_Modify(){ //float mark1,mark2,mark3; while(1) { char id[20]; int index; printf锛堬紓璇疯緭鍏ヨ淇敼鐨勫鐢熺殑瀛﹀彿锛氾紓锛夛紱 scanf(锛?s锛?&id); getchar(); index=Student_SearchByIndex(id); if (index==-1) { printf锛堬紓瀛︾敓涓嶅瓨鍦紒\n锛傦級; } else { printf锛堬紓浣犺淇敼鐨勫鐢熶俊鎭负锛歕n锛傦級; Student_DisplaySingle(index); printf锛堬紓-- 璇疯緭鍏ユ柊鍊?-\n锛傦級; printf锛堬紓璇疯緭鍏ュ鍙凤細锛傦級锛?scanf(锛?s锛?&students[index].ID); getchar(); printf锛堬紓璇疯緭鍏ュ鍚嶏細锛傦級锛?scanf(锛?s锛?&students[index].Name); getchar(); printf锛堬紓璇疯緭鍏ユ垚缁╋細锛傦級锛?scanf(锛?f锛?&students[index].Mark1); getchar(); printf锛堬紓璇疯緭鍏ユ垚缁╋細锛傦級锛?scanf(锛?f锛?&students[index].Mark2); getchar(); printf锛堬紓璇疯緭鍏ユ垚缁╋細锛傦級锛?scanf(锛?f锛?&students[index].Mark3); getchar(); students[index].Average=Avg(students[index]); } printf锛堬紓鏄惁缁х画锛燂紙y/n锛夛紓); if (getchar()=='n') { break锛?} }}/*鍒犻櫎瀛︾敓淇℃伅*/void Student_Delete(){ int i; while(1) { char id[20]; int index; printf锛堬紓璇疯緭鍏ヨ鍒犻櫎鐨勫鐢熺殑瀛﹀彿锛氾紓锛夛紱 scanf(锛?s锛?&id); getchar(); index=Student_SearchByIndex(id); if (index==-1) { printf锛堬紓瀛︾敓涓嶅瓨鍦紒\n锛傦級; } else { printf锛堬紓浣犺鍒犻櫎鐨勫鐢熶俊鎭负锛歕n锛傦級; Student_DisplaySingle(index); printf锛堬紓鏄惁鐪熺殑瑕佸垹闄わ紵锛坹/n锛夛紓); if (getchar()=='y') { for (i=index;i { students[i]=students[i+1]锛?/鎶婂悗杈圭殑瀵硅薄閮藉悜鍓嶇Щ鍔?} num--; } getchar(); } printf锛堬紓鏄惁缁х画锛燂紙y/n锛夛紓); if (getchar()=='n') { break锛?} }}/*鎸夊鍚嶆煡璇?/void Student_Select(){ while(1) { char name[20]; int index; printf锛堬紓璇疯緭鍏ヨ鏌ヨ鐨勫鐢熺殑濮撳悕锛氾紓锛夛紱 scanf(锛?s锛?&name); getchar(); index=Student_SearchByName(name); if (index==-1) { printf锛堬紓瀛︾敓涓嶅瓨鍦紒\n锛傦級; } else { printf锛堬紓浣犺鏌ヨ鐨勫鐢熶俊鎭负锛歕n锛傦級; Student_DisplaySingle(index); } printf锛堬紓鏄惁缁х画锛燂紙y/n锛夛紓); if (getchar()=='n') { break锛?} }}/*鎸夊钩鍧囧€兼帓搴?/void Student_SortByAverage(){ int i,j; struct Student tmp; for (i=0;i { for (j=1;j { if (students[j-1].Average { tmp=students[j-1]; students[j-1]=students[j]; students[j]=tmp锛?} } }}/*鏄剧ず瀛︾敓淇℃伅*/void Student_Display(){ int i; printf(锛?10s%10s%8s%8s%8s%10s\n锛傦紝锛傚鍙凤紓锛岋紓濮撳悕锛傦紝锛傛垚缁╋紓锛岋紓鎴愮哗锛傦紝锛傛垚缁╋紓锛岋紓骞冲潎鎴愮哗锛?锛?printf(锛?------------------------------------------------------------\n锛?; for (i=0;i { printf(锛?10s%10s%8.2f%8.2f%8.2f%10.2f\n锛?students[i].ID,students[i].Name, students[i].Mark1,students[i].Mark2,students[i].Mark3,students[i].Average)锛?}}/*灏嗗鐢熶俊鎭粠鏂囦欢璇诲嚭*/void IO_ReadInfo(){ FILE *fp; int i; if ((fp=fopen(锛侱atabase.txt锛?锛俽b锛?)==NULL) { printf锛堬紓涓嶈兘鎵撳紑鏂囦欢锛乗n锛傦級; return; } if (fread(&num,sizeof(int),1,fp)!=1) { num=-1; } else { for(i=0;i { fread(&students[i],sizeof(struct Student),1,fp); } } fclose(fp)锛泒/*灏嗗鐢熶俊鎭啓鍏ユ枃浠?/void IO_WriteInfo(){ FILE *fp; int i; if ((fp=fopen(锛侱atabase.txt锛?锛倃b锛?)==NULL) { printf锛堬紓涓嶈兘鎵撳紑鏂囦欢锛乗n锛傦級; return; } if (fwrite(&num,sizeof(int),1,fp)!=1) { printf锛堬紓鍐欏叆鏂囦欢閿欒锛乗n锛傦級; } for (i=0;i { if (fwrite(&students[i],sizeof(struct Student),1,fp)!=1) { printf锛堬紓鍐欏叆鏂囦欢閿欒锛乗n锛傦級; } } fclose(fp)锛泒/*涓荤▼搴?/void main(){ int choice; IO_ReadInfo(); while(1) { /*涓昏彍鍗?/ printf(锛俓n------ 瀛︾敓鎴愮哗绠$悊绯荤粺------\n锛?; printf(锛?. 澧炲姞瀛︾敓璁板綍...

杞浇璇锋敞鏄庡嚭澶?a href="http://icarastudy.com/">缁忔祹绠$悊缃?/a> » c璇█ 瀛︾敓淇℃伅绠$悊绯荤粺