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(' ',w); 14 s=0; 15 } 16 } 17 } 18 return 0; 19 }
test.c
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 }
test1.c
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 }
find.c
1 #!/bin/sh 2 # 初始文件 0里面存储的是昨晚的列表 1里面存储的是新列表 3 # wait_done是最终待做的题目列表 4 make test 5 make test1 6 make find 7 ./test 1 2 8 ./test1 2 3 9 rm 1 2 10 mv 3 1 11 ./test 0 2 12 ./test1 2 3 13 mv 3 0 14 rm 2 15 ./find 0 1 2 16 rm 0 1 17 sort -u 2 > wait_done 18 rm 2
写了一个脚本来实现,这也算是一个小程序吧!