文件获取字符数据模板
#include<stdio.h>#include<stdio.h>int main(){FILE *a,*b,*c;char x[100];int i=0;char temp;if((a=fopen("19.6.a.txt","r"))==NULL){printf("cannot open file");return 0;}if((b=fopen("19.6.b.txt","r"))==NULL){printf("cannot open file");return 0;}while(!feof(a)){temp=fgetc(a);if((temp<='z' & temp >='a') | (temp >= 'A' &temp <= 'Z')){x[i]=temp;i++;}}while(!feof(b)){temp=fgetc(b);if((temp<='z' & temp >='a') | (temp >= 'A' &temp <= 'Z')){x[i]=temp;i++;}}for(int j=0;j<i;j++){for(int m=0;m<i-j-1;m++){if(x[m] > x[m+1]){temp=x[m];x[m]=x[m+1];x[m+1]=temp;}}}if((c=fopen("19.6.c.txt","w")) == NULL){printf("cannot open file");return 0;}//fprintf(c,"%s",x);for(int j=0;j<i;j++){fputc(x[j],c);}return 0;}
21沈航计算机考研已上岸,真题有一些还是有点难度的,当时挺头疼,现在分享出来,算法思路感觉有点啰嗦,欢迎交流