仅供参考,欢迎指正。
----------------------------
#include<stdio.h>
#include<malloc.h>
#include<stdlib.h>
#include<string.h>
void main()
{
int a,b,c,p;
int n;
int i=0;
int len[100];
memset(len,0,100*sizeof(int));
float area=0,s;
printf("input the quantity of sticks.\n");
scanf("%d",&n);
if(n<3)
{
printf("the sticks is not enough!\n");
system("pause");
return;
}
printf("input the length of sticks(Ascending).\n");
for (i;i<n;i++)
scanf("%d",&len[i]);
for(c=n-1;c>1;c--)
{
for(b=c-1;b>0;b--)
{
p=len[b]*len[b]+len[b-1]*len[b-1];
if(len[c]*len[c]>p)
break;
for(a=b-1;a>=0;a--)
{
p=len[b]*len[b]+len[a]*len[a];
if(len[c]*len[c]>p)
break;
if(len[c]*len[c]==p)
{
s=len[a]*len[b]/2;
if(s>area)
area=s;
}
}
}
}
if(area==0)
printf("My God!\n");
printf("the area is %.3f\n",area);
system("pause");
}