diff --git a/c1.c b/c1.c new file mode 100644 index 0000000..6fc9b42 --- /dev/null +++ b/c1.c @@ -0,0 +1,37 @@ +void input() //³É¼¨ÊäÈë +{ + Student s[50]; + system("cls"); + int i=0; + FILE *fp; + fp=fopen("a.txt","a+"); + printf("ÇëÒÔ0×÷ΪÊäÈëѧÉúѧºÅÐÅÏ¢µÄ½áÊø£¡\n"); + do + { + printf("ÊäÈëѧÉúµÄѧºÅ£º"); + scanf("%lf",&s[i].no); + printf("ÊäÈëѧÉúµÄÐÕÃû£º"); + scanf("%s",s[i].name); + printf("ÊäÈëѧÉúµÄCÓïÑԳɼ¨£º"); + scanf("%f",&s[i].cscore); + if(s[i].no!=0) + fprintf(fp,"%.0lf %-4s %.1f\n",s[i].no,s[i].name,s[i].cscore); + }while(s[i].no!=0); + fclose(fp); +} +void output() //³É¼¨Êä³ö +{ + if((fp=fopen("a.txt","r"))==NULL) + { + printf("Cannot open the file!\n"); + + } + printf("\t\t\tÈ«²¿µÄѧÉúÐÅÏ¢£º\n"); + int k=0; + while(fscanf(fp,"%lf%s%f",&s[k].no,s[k].name,&s[k].cscore)!=EOF) + { + printf("\t\t\t%.0lf\t%s\t%.1f\n",s[k].no,s[k].name,s[k].cscore); + k++; + } + fclose(fp); +} diff --git a/c2.c b/c2.c new file mode 100644 index 0000000..05f319d --- /dev/null +++ b/c2.c @@ -0,0 +1,107 @@ +void modify() //³É¼¨ÐÞ¸Ä +{ + char st[30]; + double x,num; + float nu; + int k=0; + system("cls"); + if((fp=fopen("a.txt","r"))==NULL) + { + printf("Cannot open the file!\n"); + return; + } + while(fscanf(fp,"%lf%s%f",&s[k].no,s[k].name,&s[k].cscore)!=EOF) + { + k++; + } + fclose(fp); + + printf("ÊäÈë1±íʾÓÃѧºÅÐ޸ģ¬ÊäÈë2±íʾÓÃÐÕÃûÐ޸ģ¡ÇëÑ¡Ôñ£º\n"); + scanf("%lf",&x); + if(x==1) + { + printf("ÇëÊäÈëÐ޸ijɼ¨È˵ÄѧºÅ£º"); + scanf("%lf",&num); + int i; + for(i=0;i=90) + printf("\t\t\t%.0lf %s %.1f\n",s[i].no,s[i].name,s[i].cscore); + printf("\n\n"); + printf("\t\t\t 80µ½89·ÖѧÉúµÄÐÅÏ¢!\n"); + for(i=0;i=80) + printf("\t\t\t%.0lf %s %.1f\n",s[i].no,s[i].name,s[i].cscore); + printf("\n\n"); + printf("\t\t\t 60µ½79·ÖѧÉúµÄÐÅÏ¢!\n"); + for(i=0;i=60&&s[i].cscore<80) + printf("\t\t\t%.0lf %s %.1f\n",s[i].no,s[i].name,s[i].cscore); + printf("\n\n"); + printf("\t\t\t 60·ÖÒÔÏÂѧÉúµÄÐÅÏ¢!\n"); + for(i=0;i=60) + j++; + } + for(i=0;i