1 #include <stdio.h> 2 int main(int argc,char **argv){ 3 FILE *r=fopen(argv[1],"r"); 4 FILE *w=fopen(argv[2],"w"); 5 char t; 6 int cnt,s=0; 7 while((t=fgetc(r))!=EOF){ 8 if(t>=‘0‘&&t<=‘9‘){ 9 fputc(t,w); 10 s=1; 11 }else { 12 if(s==1){ 13 fputc(‘\n‘,w); 14 s=0; 15 } 16 } 17 } 18 return 0; 19 }
1 #include <stdio.h> 2 #include <string.h> 3 int main(int argc,char **argv){ 4 FILE *r=fopen(argv[1],"r"); 5 FILE *w=fopen(argv[2],"w"); 6 char buff[10000]; 7 while(NULL!=fgets(buff,10000,r)){ 8 if(strlen(buff)==5){ 9 fputs(buff,w); 10 } 11 } 12 return 0; 13 }
1 #include <stdio.h> 2 #include <string.h> 3 int main(int argc,char **argv){ 4 int cnt=0; 5 int i,j; 6 char list[10000][10]; 7 FILE *r1=fopen(argv[1],"r"); 8 FILE *r2=fopen(argv[2],"r"); 9 FILE *w=fopen(argv[3],"w"); 10 char buff[10]; 11 while(NULL!=fgets(buff,10,r1)){ 12 strcpy(list[cnt++],buff); 13 } 14 while(NULL!=fgets(buff,10,r2)){ 15 int s=0; 16 for(i=0;i<cnt;++i){ 17 if(strcmp(list[i],buff)==0){ 18 s=1; 19 break; 20 } 21 } 22 if(s==0){ 23 fputs(buff,w); 24 } 25 } 26 return 0; 27 }