1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
|
#pragma comment(lib, "winmm.lib")
#include <windows.h>
#include <mmsystem.h>
#include <string>
#define MAX_BUFFER 256
std::string strFilename = "JWC_TEMP.TXT";
int main(int argc,char *argv[]){
//コマンド引数
int nParam = atoi(argv[1]);
FILE *fp = fopen(strFilename.c_str(),"r");
if(!fp)return 0;
char strBuffer[MAX_BUFFER];
std::string strLine;
while(fgets(strBuffer,MAX_BUFFER,fp) != NULL){
strLine = strBuffer;
if(strLine.find("hp1",0) != std::string::npos){
//指定点座標に該当するとき。座標を実数で取得。
std::string str2 = strLine.substr(3);
while(str2.at(0) == ' ')str2 = str2.substr(1);
std::string strX = str2.substr(0,str2.find(" ",0));
std::string strY = str2.substr(str2.find(" ",0) + 1);
double nX = atof(strX.c_str());
double nY = atof(strY.c_str());
fclose(fp);
//出力
fp = fopen(strFilename.c_str(),"w");
//擬似乱数により半径を計算
timeBeginPeriod(1);
srand((unsigned)timeGetTime());
double nRadius = nParam + nParam * (0.01 * (rand() % 100));
timeEndPeriod(1);
//円を出力する
sprintf(strBuffer,"ci %lf %lf %d 0 360 1 0\n",nX,nY,nRadius);
fputs(strBuffer,fp);
fclose(fp);
return 0;
}
}
return 0;
}
|