C/C++の宿題を片付けます 100at TECH
C/C++の宿題を片付けます 100 - 暇つぶし2ch258:デフォルトの名無しさん
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);
}


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch