jjt1018489501 于 2015.07.11 22:16 提问

#include
#include
#include
#include
#define shuliang 10000
#define gaodu 1024
#define kuandu 1024
using namespace std;
static int yuanxinx = 0;
static int yuanxiny = 0;
static int jiaodianax = 0;
static int jiaodianay = 0;
static int jiaodianbx = 0;
static int jiaodianby = 0;
static int count1 = 0;
const double pi = 3.1415927;
int juli(int a, int b,int c , int d)//输入两个点的坐标，计算两点间距离
{

return sqrt(pow((a - c), 2) + pow((b - d), 2));
}
bool yuanxin(int ax, int ay, int bx, int by, int cx, int cy)//输入三个点坐标，计算圆心
{
int a, b, c;
bool i=1;
for (int x = 0; x <= gaodu; x++)
{
for (int y = 0; y <= kuandu; y++)
{
a = pow((x - ax), 2) + pow((y - ay), 2);
b = pow((x - bx), 2) + pow((y - by), 2);
c = pow((x - cx), 2) + pow((y - cy), 2);
if (fabs(a-b)<exp(-5)&&fabs(c-b)<exp(-5))
{
yuanxinx = x;
yuanxiny = y;
return i;
break;
}
else i = 0;
return i;
}
}

}
bool zhaojiaodian(int ax, int ay, int a[shuliang][3],int qiyaa,int qiyab)//输入圆心和所有点，寻找所需焦点
{

int d, e, f;
double g1;
double g2;
double h1;
double h2;
int angle;
bool p=1;

for (int n = 0; n <= shuliang; n++)
{

for(int dx = 0;dx<=kuandu;dx++)
{

for(int ex = 0;ex <= kuandu;ex++)
{
for (int dy = 0;dy <= gaodu; dy++)
{

for(int ey =0 ;ey <= gaodu; ey++)
{
if ((a[n][1] == ex && a[n][2] == ey)||(a[n][1] == dx && a[n][2] == dy))
{

d = sqrt(pow(ax-dx,2) + pow(ay-dy,2));
e = sqrt(pow(ax-ex,2) + pow(ay-ey,2));
f = sqrt(pow(dx-ex,2) + pow(dy-ey,2));
if (fabs(e-f-d)<exp(-5))
{
for(int i = 0 ;i <= 4 ; i++)
{
g1 = (ay-dy)/(ax-dx);
g2 = 0;
h1 = atan(g1);
h2 = atan(g2);
angle = fabs(h1 - h2);
if (fabs(angle- i*pi/4)<exp(-5))
{
jiaodianax = dx;
jiaodianay = dy;
jiaodianbx = ex;
jiaodianby = ey;
return p;
break;
}
else p = 0;
return p;
}
}
}
}
}
}
}
}
}
int zhongzhidianx(int ax, int bx)
{
return ax + (bx - ax) / 2;
}
int zhongzhidiany(int ay,int by)
{
return ay + (by - ay) / 2;
}
void main()
{
int a[shuliang][3]; //建立二维数组

``````ifstream infile("input.txt", ios::in);  //打开已存在的输入文件input.txt
if (!infile)
{
cout << "输入文件input.txt不存在\n";
exit(0);
}
ofstream outfile;                              //创建输出文件，若存在则清除该文件内容
outfile.open("output.txt", ios::out);
if (!outfile)
{
cout << "不能建立输出文件output.txt\n";
exit(0);
}
char str[2000][20];
int i = 0;
while (!infile.eof())
{
infile.getline(str[i], 20);
i++;
}
count1 = i;
int flag = 0;
int value = 0;
for (int k = 0; k <= count1; k++)
{
flag = 0;
value = 0;
for (int l = 0; str[k][l] != '\0'; l++)
{
if (str[k][l] != '\t')
{
value = value * 10 + (str[k][l] - '0');
}
if (str[k][l] == '\t' || str[k][l + 1] == '\0')
{
a[k][flag] = value;
value = 0;
flag++;
}
}

}
``````
``````    }
}
infile.close();
outfile.close();
``````

}

3个回答

devmiao      2015.07.11 22:20
jjt1018489501 这个我之前已经看过了。。对我这程序帮助并不大。。现在就把我上面程序改到outfile出结果就可以了。。
2 年多之前 回复
jjt1018489501   2015.07.11 22:24

oyljerry      2015.07.11 23:45