07/11/27 01:45:34
>>247
#include <stdio.h>
main()
{
int x , y, old_x = 0, old_y = 0, a = 0;
char line[1000];
FILE *fin,*fout;
if((fin=fopen("sample.txt","r"))==NULL){
printf("sample.txt can't open.\n");
exit(1);
}
if((fout=fopen("result.txt","w"))==NULL){
printf("result.txt can't open.\n");
exit(1);
}
while(fgets(line,1000,fin)!=NULL){
sscanf(line,"%d,%d",&x,&y);
if(y - old_y >= 0){
old_x = x; old_y = y;
a = 1;
}else{
if (a == 1){
fprintf(fout,"[%d,%d]\n",old_x,old_y);
}
old_x = x; old_y = y;
a = 0;
}
}
fclose(fin);
fclose(fout);
}