c程序设计第四版(谭浩强)第十章答案 下载本文

内容发布更新时间 : 2025/1/22 1:48:42星期一 下面是文章的全部内容请认真阅读。

#include #include #include /*

int main() { FILE *p; char a; if((p=fopen(\ { printf(\ exit(0); } printf(\以!结束):\ a=getchar(); while(a!='!') { if(a>='a'&&a<='z') a=a-32; fputc(a,p); putchar(a); a=getchar(); } fclose(p); putchar('\\n'); } */ /*

void sort(char b[]) { int n=strlen(b),i,j; char k; for(i=1;ib[j]) { k=b[i-1]; b[i-1]=b[j]; b[j]=k; } }

int main() { FILE *p1,*p2,*p3;

char b[20],c[20]; int i=0; if((p1=fopen(\ { printf(\ exit(0); } if((p2=fopen(\ { printf(\ exit(0); } if((p3=fopen(\ { printf(\ exit(0); } printf(\ while(!feof(p1)) { b[i]=getc(p1); putchar(b[i]); i+=1; }

putchar(10); fclose(p1); i-=1; //?不这样的话会出现空格 printf(\ while(!feof(p2)) { b[i]=getc(p2); putchar(b[i]); i+=1; } b[i-1]='\\0'; //? sort(b); fputs(b,p3); rewind(p3); //读取光标移动头部 putchar(10); fclose(p2); if(fgets(c,20,p3)!=NULL) printf(\ putchar(10); fclose(p3);

} */ /*

#define n 5 struct student { long num; char name[10]; float score[3]; float ave; }stu[5]; void save() { int i; if((p=fopen(\ { printf(\ return; }

for(i=0;i

int main() { int i; printf(\ for(i=0;i

10101 wu 70 71 90 10102 chen 60 64 90 10103 guo 80 78 90 10104 lu 80 64 90 10105 xu 60 65 90

*/ /*

#define n 5 struct student { long num; char name[10]; float score[3]; float ave; }stu[5];

void sort(struct student stu[]) { int i,j; struct student k; for(i=1;istu[j].ave) { k=stu[i-1]; stu[i-1]=stu[j]; stu[j]=k; } }

int main() { FILE *p; int i; if((p=fopen(\ { printf(\ exit(0); } for(i=0;i

} for(i=0;i

#define n 6 struct student { long num; char name[10]; float score[3]; float ave; }stu[n];

void sort(struct student stu[]) { int i,j; struct student k; for(i=1;istu[j].ave) { k=stu[i-1]; stu[i-1]=stu[j]; stu[j]=k; } }

int main() { FILE *p,*p1; int i; if((p=fopen(\ { printf(\ exit(0); } printf(\ for(i=0;i