#include<stdio.h>
#include<math.h>
#define PI 3.1416
main()
{
float u,alpha,g,height;
g=9.81;
printf("Enter the initial velocity and the angle (in degree):");
scanf("%f %f",&u,&alpha);
if(alpha<0 || alpha>180)
{
printf("Input angle should lie between 0 and 180.\n");
}
else
{
height=u*u*pow(sin(alpha*PI/180.0000),2)/2*g;
printf("The maximun height is %.4f m\n",&height);
}
}
运算不出结果呀,如果我输入角度少过180 的结果 都 是0。
还是要用sin(alpha*PI/180)*sin(alpha*PI/180)