我做的三角形找到perameters此代码为直角三角形 但输出似乎出来的权利,但反复我的代码输出重复
#include<iostream>
#include<vector>
#include<list>
#include <math.h>
#include <algorithm>
using namespace std;
int main()
{
int a;
float c;
vector<double> retval;
double intiger;
double p;
double l = 25;
float array[3];
for (int b=1; b < l; b++) {
for (int a=1; a < l; a++) {
intiger = sqrt((b*b)+(a*a));
c = sqrt((b*b)+(a*a));
if (c == intiger) {
array[0]=a;
array[1]=b;
array[2]=c;
//int elements = sizeof(array);
//cout << elements << endl;
sort(array, array +3);
//retval.push_back(a);
//retval.push_back(b);
//retval.push_back(c);
if (c == a) {
continue;
}
p = a + b + c;
if (p > l) {
break;
}
//cout << "p == " << p << endl;
} else {
continue;
}
//if (retval.size()== 62)
//cout << c <<endl;
//cout << " a = " << a << " b = " << b << " c = " << c << " "
cout << array[0] << " " << array[1] << " " << array[2] << endl;
}
}
return 0;
}
输出出来要重复两次。
3 4 5
3 4 5
6 8 10
6 8 10
我想让它重复一次。
请您缩进码。 – 2012-03-11 02:48:05
将“cout”向下移动1行,在}之后。 – TreyA 2012-03-11 02:48:16
我移动了cout,但代码出来了,但它仍然重复 – user1261771 2012-03-11 02:54:57