欢迎来到天天文库
浏览记录
ID:38155225
大小:14.56 KB
页数:4页
时间:2019-06-06
《C语言入门与经典程序集锦》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、#includemain(){inta,b;printf("请输入一个整数以求它的立方:");scanf("%d",&a);//scanf_s("%d",&a);b=a*a*a;printf("%d的立方为%d",a,b);}//求立方#include#include#includemain(){inta;srand(time(NULL));a=rand()%8+3;//a到b之间的随机数rand()%(b-a+1)+aprintf("3到10之间的随机数为%d",a);
2、}//产生随机数#include#definen4intmain(){inti,j;inta[n];voidsort(int*p,intm);printf("请输入要排序的数:");for(i=0;i3、m-r-1;s++){if(p[s]>p[s+1]){t=p[s];p[s]=p[s+1];p[s+1]=t;}}}}//冒泡法排序#include#definen5intmain(){inti,j;inta[n];voidsort(int*p,intm);printf("请输入要排序的数:");for(i=0;i4、}voidsort(int*p,intm){intr,s,t,z;for(r=0;r#defineN2structstudent{charnum[3];charname[6];floatscore[4];}stu[N+1];intmain(){voidprint(structstudentstu[N]);voidsave(structs5、tudentstu[N]);voidrange(structstudentstu[N]);inti,j;for(i=0;i6、stu[i].score[0]+stu[i].score[1]+stu[i].score[2])/3;printf("");}range(stu);save(stu);print(stu);return0;}voidrange(structstudentstu[N]){intr,s,t;for(r=0;r7、}}voidsave(structstudentstu[N]){inti,j;FILE*fp;fp=fopen("F:\grade.txt","a+");fprintf(fp,"NO.namescore1score2score3average");for(i=0;i8、fprintf(fp,"");}fclose(fp);}voidprint(structstudents
3、m-r-1;s++){if(p[s]>p[s+1]){t=p[s];p[s]=p[s+1];p[s+1]=t;}}}}//冒泡法排序#include#definen5intmain(){inti,j;inta[n];voidsort(int*p,intm);printf("请输入要排序的数:");for(i=0;i4、}voidsort(int*p,intm){intr,s,t,z;for(r=0;r#defineN2structstudent{charnum[3];charname[6];floatscore[4];}stu[N+1];intmain(){voidprint(structstudentstu[N]);voidsave(structs5、tudentstu[N]);voidrange(structstudentstu[N]);inti,j;for(i=0;i6、stu[i].score[0]+stu[i].score[1]+stu[i].score[2])/3;printf("");}range(stu);save(stu);print(stu);return0;}voidrange(structstudentstu[N]){intr,s,t;for(r=0;r7、}}voidsave(structstudentstu[N]){inti,j;FILE*fp;fp=fopen("F:\grade.txt","a+");fprintf(fp,"NO.namescore1score2score3average");for(i=0;i8、fprintf(fp,"");}fclose(fp);}voidprint(structstudents
4、}voidsort(int*p,intm){intr,s,t,z;for(r=0;r#defineN2structstudent{charnum[3];charname[6];floatscore[4];}stu[N+1];intmain(){voidprint(structstudentstu[N]);voidsave(structs
5、tudentstu[N]);voidrange(structstudentstu[N]);inti,j;for(i=0;i6、stu[i].score[0]+stu[i].score[1]+stu[i].score[2])/3;printf("");}range(stu);save(stu);print(stu);return0;}voidrange(structstudentstu[N]){intr,s,t;for(r=0;r7、}}voidsave(structstudentstu[N]){inti,j;FILE*fp;fp=fopen("F:\grade.txt","a+");fprintf(fp,"NO.namescore1score2score3average");for(i=0;i8、fprintf(fp,"");}fclose(fp);}voidprint(structstudents
6、stu[i].score[0]+stu[i].score[1]+stu[i].score[2])/3;printf("");}range(stu);save(stu);print(stu);return0;}voidrange(structstudentstu[N]){intr,s,t;for(r=0;r7、}}voidsave(structstudentstu[N]){inti,j;FILE*fp;fp=fopen("F:\grade.txt","a+");fprintf(fp,"NO.namescore1score2score3average");for(i=0;i8、fprintf(fp,"");}fclose(fp);}voidprint(structstudents
7、}}voidsave(structstudentstu[N]){inti,j;FILE*fp;fp=fopen("F:\grade.txt","a+");fprintf(fp,"NO.namescore1score2score3average");for(i=0;i8、fprintf(fp,"");}fclose(fp);}voidprint(structstudents
8、fprintf(fp,"");}fclose(fp);}voidprint(structstudents
此文档下载收益归作者所有