|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
double Area(double a , double b ,double c)
{
double s;
double area;
s = (a + b + c)/(2.0);
area = sqrt( s * ( s - a ) * (s - b) * (s - c));
return area;
}
int main(void)
{
int TrangCount;
printf("平方:%f",pow(2,4));
scanf("%d",&TrangCount);
double PointSum[TrangCount][2];
for(int i = 0; i <TrangCount;i++)
{
scanf("%d %d",&PointSum[i][0], &PointSum[i][1]);
printf("Pointsum%d %d\n",PointSum[i][0],PointSum[i][1]);
}
printf("Pointsum%d %d\n",PointSum[0][0],PointSum[0][1]);
double AllLine[100000];
int LineCount = 0;
for(int i = 0; i <= TrangCount - 2; i ++)
{
for(int j = i + 1; j <= TrangCount - 1; j++)
{
printf("ForPointsum%d %d\n",PointSum[i][0],PointSum[i][1]);
AllLine[LineCount] = ((double)((PointSum[i][0] - PointSum[j][0]) * (PointSum[i][0] - PointSum[j][0]) +
(PointSum[i][1] - PointSum[j][1]) * (PointSum[i][1] - PointSum[j][1])));
printf(" qianbanbufen: %d %d %d %d\n",PointSum[i][0] ,PointSum[i][1], PointSum[j][0], PointSum[j][1]);
printf(" sqrt%d m\n",(PointSum[i][0] - PointSum[j][0])*(PointSum[i][0] - PointSum[j][0]) );
printf("PointSum[i][0] - PointSum[j][0]%d\n",(PointSum[i][0] - PointSum[j][0]));
printf("(PointSum[i][0] - PointSum[j][0])*(PointSum[i][0] - PointSum[j][0]) %d\n",(PointSum[i][0] - PointSum[j][0])*(PointSum[i][0] - PointSum[j][0]));
printf("shishu %d\n",32 * 32);
printf("%lfAllLIne\n",AllLine[LineCount]);
LineCount++;
}
}
double biggest = 3;
double New;
for(int one = 0; one <= LineCount - 3;one++)
{
for(int two = one + 1; two <= LineCount - 2;two++)
{
for(int three = two + 1;three <= LineCount - 1;three++)
{
New= Area(AllLine[one],AllLine[two],AllLine[three]);
printf("one:%d two:%d three;%d New:%d %d %d %d \n",one ,two ,three,New,AllLine[one],AllLine[two],AllLine[three]);
if( biggest < New)
{
biggest = New;
}
}
}
}
printf("%f",biggest);
return 0;
}
为什么printf("PointSum[i][0] - PointSum[j][0]%d\n",(PointSum[i][0] - PointSum[j][0])); %d显示的不是0,
而 printf("(PointSum[i][0] - PointSum[j][0])*(PointSum[i][0] - PointSum[j][0]) %d\n",(PointSum[i][0] - PointSum[j][0])*(PointSum[i][0] - PointSum[j][0]));%d而是0 |
|