#include<iostream>
using namespace std;
void QuickSort(int e[], int first, int end)
{
int i = first, j = end;
int temp = e[first];//记录第一个数据
while (i<j)
{
while (i<j && e[j] >= temp) //与first数据比较,右边下标逐渐左移
j--;
e[i] = e[j];
while (i<j && e[i] <= temp) //与first数据比较,左边下标逐渐右移
i++;
e[j] = e[i];
}
e[i] = temp; //将first数据放置于i=j处
if (first<i - 1)
QuickSort(e, first, i - 1);
if (end>i + 1)
QuickSort(e, i + 1, end);
}
void main()
{
int n;
while (cin>>n)
{
int count=0;
int *len = new int[n];
for (int i = 0; i < n; i++) cin >> len[i];
QuickSort(len, 0, n-1);
for (int a = 0; a < n; a++)
{
for (int b = a+1; b < n; b++)
{
for (int c = b+1; c < n; c++)
{
if (len[a]+len[b]>len[c])
count++;
else break;
}
}
}
cout << count << endl;
}
}
Input题目有多组数据,对于每组数据,第一行为一个整数n(3Output对于每组数据输出方案数。Sample Input41 2 3 431 2 3Sample Output10#includeusing namespace std;void QuickSort(int e[], int first, int end){ int i = fir