正在加载图片...
char s[100],t[100],u[100 printf("\nPlease S: " ) scanf(%s",s) printf("\nPlease scanf (%s", t) 二、编程题(22分) #include "stdio. h f FILE*fp char c[ 160], t, ch; if((fp=fopen("A","I)F=NULL) i printf("file A cannot be opened n") ext(0);} printf("\n A contents are: In") for(i=0 (ch=fgetc(fp))I=EOF; 1++) ici]=ch; (c[) if(fp=fopen("B", r)-NULL printf("file B cannot be opened\n"); exit(O); j printf("\n B contents are: n"); for(i0; (ch=fgetc(fp))=EOF; 1++) putchar(cli: for(i=0; i<n; i++) if(c]>cD it=c; ci=cll: cll=t tf("\n C file is: \n") i putc(c i], fp); putchar(c[可12 main() { char s[100], t[100], u[100]; clrscr(); printf("\nPlease enter string s:"); scanf("%s", s); printf("\nPlease enter string t:"); scanf("%s", t); fun(s, t, u); printf("the result is: %s\n", u); } 二、编程题(22 分) #include "stdio.h" main() { FILE *fp; int i,j,n,ni; char c[160],t,ch; if((fp=fopen("A","r"))==NULL) {printf("file A cannot be opened\n"); exit(0);} printf("\n A contents are :\n"); for(i=0;(ch=fgetc(fp))!=EOF;i++) {c[i]=ch; putchar(c[i]); } fclose(fp); ni=i; if((fp=fopen("B","r"))==NULL) {printf("file B cannot be opened\n"); exit(0);} printf("\n B contents are :\n"); for(i=0;(ch=fgetc(fp))!=EOF;i++) {c[i]=ch; putchar(c[i]); } fclose(fp); n=i; for(i=0;i<n;i++) for(j=i+1;j<n;j++) if(c[i]>c[j]) {t=c[i];c[i]=c[j];c[j]=t;} printf("\n C file is:\n"); fp=fopen("C","w"); for(i=0;i<n;i++) { putc(c[i],fp); putchar(c[i]); }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有