/ Vijos / 讨论 / 问答 /

训练题珠心算不知哪错了

#include<iostream>
#include<algorithm>
using namespace std;
int i, j, x;
int main()
{
int num,sum=0;
cin >> num;
int *remember=new int[num];
for (int i = 0; i < num; i++)
{
cin >> remember[i];
}
sort(remember, remember + num);
for ( i = 2; i < num; i++)
{
for ( j = 0; j <=i - 2; j++)
{
for ( x = j + 1; x<= i- 1; x++)
{
if ((remember[j] + remember[x]) == remember[i])
{
sum++;
}
}
}
}
cout << sum << endl;
//system("pause");
return 0;
}

0 条评论

目前还没有评论...