diff --git a/2.c b/2.c new file mode 100644 index 0000000..c653df3 --- /dev/null +++ b/2.c @@ -0,0 +1,106 @@ +int info_show() //´òÓ¡ËùÓÐÐÅÏ¢ +{ int i; + for(i=0;ist[snum].score[j]) + { + mi=st[snum].score[j]; + } + if(ma //±àÒëÔ¤´¦ÀíÃüÁî +#include //¶¨ÒåÔÓÏÊý¼°ÄÚ´æ·ÖÅ亯Êý +#include //×Ö·û´®´¦Àí +#include //Óõ½ÁËtimeº¯Êý +int main() +{ + int num=0; + while(1) + { + system("cls"); + load(); + printf("|----¸è³ª±ÈÈü¹ÜÀíϵͳ----\n"); + printf("\n ----------------------\n"); + printf("| [1] ²ÎÈü¸èÊÖÐÅϢ¼Èë |\n"); + printf("| [2] ²ÎÈü¸èÊÖÐÅÏ¢ÏÔʾ |\n"); + printf("| [3] ²éѯ²ÎÈü¸èÊÖÐÅÏ¢ |\n"); + printf("| [4] ÐÞ¸ÄÆÀί´ò·Ö |\n"); + printf("| [5] ²éѯ³ö³¡´ÎÐò |\n"); + printf("| [6] ±ÈÈü½á¹ûÅÅÐò |\n"); + printf("| [7] Í˳öϵͳ |\n"); + printf(" ----------------------\n"); + printf("ÇëÑ¡ÔñÒª½øÐеIJÙ×÷:"); + scanf("%d",&num); + switch(num)//²Ëµ¥ + { + case 1 : info_sign();break;//¼Èë + case 2 : info_show();break;//ÏÔʾ + case 3 : info_find();break;//²éÕÒ + case 4 : grade_modify();break;//ÐÞ¸Ä + case 5 : find_order();break; + case 6 : result_sort();break; + case 7 : exit(0); + } + } +} +struct node{ + int id;//±àºÅ + char name[20];//ÐÕÃû + double score[11];//³É¼¨ + double sum;//ƽ¾ù·Ö + +}st[100],s; +int snum=0; +int load() /********************************************¼ÓÔØÎļþÊý¾Ýµ½ÄÚ´æ *************************************/ +{ + snum=0; + FILE *fp; //ÉùÃ÷ÎļþÖ¸Õë + fp=fopen("info.txt","r"); //ÒÔ¶ÁµÄ·½Ê½´ò¿ªÎļþ + if(fp==NULL) + { + printf("Êý¾ÝÎļþ¼ÓÔØʧ°Ü£¬ÒÉËÆinfo.datÎļþ¶ªÊ§£¬»òÕßδµ¼ÈëÊý¾Ý\n"); + } + else{ + while(!feof(fp)){//±éÀú ÎļþÊý¾Ý + fread(&st[snum++],sizeof(struct node),1,fp); //snumÊDzÎÈüÑ¡ÊÖµÄÊýÁ¿£¬Ã¿¶ÁÈ¡Ò»ÌõÊý¾Ý¼ÓÒ»´Î¡£ + } + } + if(snum>0) + snum--; + else snum=0; + fclose(fp); + printf("Êý¾ÝÌõÊý£º%d\n",snum); + return 0; +} +int save() /**********************************½«ÄÚ´æÊý¾ÝдÈëÎļþ******************************************/ +{ + FILE *fp; + int i,t=0; + fp=fopen("info.txt","w");//ÒÔдµÄ·½Ê½´ò¿ª²ÎÈüÑ¡ÊÖÐÅÏ¢Îļþ + for(i=0;ist[snum].score[i]) + { + mi=st[snum].score[i]; + } + if(mast[snum].score[j]) + { + mi=st[snum].score[j]; + } + if(ma=0 && st[j].sum