云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 青岛科技大学大学老师C语言上机实验答案

青岛科技大学大学老师C语言上机实验答案

  • 62 次阅读
  • 3 次下载
  • 2026/1/12 17:55:12

struct student t; for(i=0;i

for(j=0;j

if(stu[j].sum

{ t=stu[j]; stu[j]=stu[j+1]; stu[j+1]=t; } }

void sort(struct student stu[ ],int p) { switch(p)

{ case 1: sortbystunum(stu); break; case 2: sortbystuname(stu); break; case 3: sortbymath(stu); break; case 4: sortbyphysics(stu); break; case 5: sortbycomputer(stu); break; case 6: sortbysum(stu); break; default: printf(\ } }

void sortselect(int *select)

{ printf(\

printspace( );

printf(\ printf(\ printf(\ printf(\ printspace( );

printf(“\\nYour choice:”); scanf(\}

void main( ) { int selectnum;

struct student stu1[N]; readinformation(stu1); sortselect(&selectnum); while(selectnum!=0)

{ sort(stu1,selectnum); printinformation(stu1); sortselect(&selectnum);

}

}

3、#include void main( )

{ FILE *fp_in,*fp_out;

char infile[20],outfile[20]; printf(“Enter the infile name:”); scanf(“%s”,infile);

printf(“Enter the outfile name:”); scanf(“%s”,outfile);

if((fp_in=fopen(infile,“r”)==NULL)

{ printf(“Can’t open file:%s”,infile); exit(1); } if((fp_out=fopen(outfile,“w”)==NULL)

{ printf(“Can’t open file:%s”,outfile); exit(1); } while(!feof(fp_in))

fputc(fgetc(fp_in),fp_out); fclose(fp_in); fclose(fp_out); }

4、#include

void main( ) { FILE *fp;

char str[100];

int i;

if((fp=fopen(“test”,“w”))==NULL) { printf(“Cannot open the file.\\n”);

exit(0); }

printf(“Input a string:”);

gets(str); /*读入一行字符串*/

for(i=0;str[i]&&i<100;i++) /*处理该行中的每一个字符*/ { if(str[i]>=‘a’&&str[i]<=‘z’) /*若是小写字母*/

str[i]-=‘a’-‘A’; /*将小写字母转换为大写字母*/ fputc(str[i],fp); /*将转换后的字符写入文件*/ }

fclose(fp); /*关闭文件*/

fp=fopen(“test”,“r”); /*以读方式打开文本文件*/ fgets(str,100,fp); /*从文件中读入一行字符串*/ printf(“%s\\n”,str);

fclose(fp); }

  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

struct student t; for(i=0;i

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com