- 论坛徽章:
- 0
|
问个删除数据记录的问题!
我来放毒草啦
- #include <stdio.h>;
- #include <stdlib.h>;
- int a[10];
- bool check(int *a)
- {
- int counter=0;
- for(int i=a[0];i>;=1;i--)
- {
- if(a[i]%2==1)counter++;
- }
- if(counter==4)
- return false;
- return true;
- }
-
- int main()
- {
- FILE *fp1,*fp2;
- a[0]=7;
- if(fp1=fopen("b.txt","r")==NULL)
- {
- printf("Open file error\n");
- exit(0);
- }
- if(fp2=fopen("btemp.txt","w")==NULL)
- {
- printf("Open file error\n");
- exit(0);
- }
- while(fscanf(fp1,"%d:%d:%d:%d:%d:%d:%d",
- &a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7])
- !=EOF)
- {
- if(check(a))
- fprintf(fp2,"%d:%d:%d:%d:%d:%d:%d\n",
- a[1],a[2],a[3],a[4],a[5],a[6],a[7]);
- }
- fclose(fp1);
- fclose(fp2);
- //system("rm -f b.txt");
- //system("mv btemp.txt b.txt");
- return 0;
- }
复制代码
虚心向mq110学习, |
|