#include
#include
void area(void)/*第二题,三角形面积计算*/
{
float a , b , c;
float p , s;
printf("\nPlease input the length of the triangle.");
scanf("%f%f%f",&a,&b,&c);
if( a+b < c || (a-b >c ) || ( b-a > c))
printf("This three number can't make a triangle !");
else
{
p=( a + b + c )/2.0;
s=sqrt( p*(p-a)*(p-b)*(p-c) );
printf("The area is %f\n", s );
}
}
void caculater(void) /*第一题*/
{
int i,j;
float s[5] , result = 0.0;
s[0]=105.0;
for( i = 1 ; i < 5 ; i++ )
s[i]=s[i-1]+21; /*相隔21计一个数*/
for( i = 0 ; i < 5 ; i++)
result += sqrt( s[i] ); /*加上一个平方根*/
printf("The result is %f\n",result);
}
/*这里用到了开方函数,sqrt(),其原型在math.h头文件中*/
1.
#include
#include
void main()
{
double sum;
int i;
sum=0;
for(i=100;i<=200;i++)
{
if(!(i%3)&&!(i%7))
sum+=sqrt(i);
}
printf("%f\n",sum);
}
#include
#include
void main()
{
float a;
float b;
float c;
float square;
float p;
printf("input the three length:");
scanf("%f%f%f",&a,&b,&c);
if(a+b>c&&a-b
printf("this is a triple\n");
p=(a+b+c)/2;
square=sqrt(p*(p-a)*(p-b)*(p-c));
printf("the square is %f\n",square);
}
else
printf("this is not a triple\n");
}
第一题:#include
#include
main()
{
int i;
float answer=0;
for(i=100;i<=200;i++)
if(i%3==0&&i%7==0)
answer+=sqrt(i);
printf("%f\n",answer);
}
第二题:
#include
#include
main()
{
float a,b,c,p,s;
printf("请输入a边的值:\n");
scanf("%f",&a);
printf("请输入b边的值:\n");
scanf("%f",&b);
printf("请输入c边的值:\n");
scanf("%f",&c);
if((a+b>c)&&(a+c>b)&&(a+b>c))
{
printf("三个边可以构成三角形\n");
putchar('\n');
p=(a+b+c)/2;
s=sqrt(p*(p-a)*(p-b)*(p-c));
printf("三边构成的三角形面积是:\n");
printf("%f\n",s);
}
else printf("三边不能构成三角形\n");
}
我都编译通过的,试了半天,你再试试吧,肯定对的!!!
第一题:
#include
#include
void main()
{
double sum;
int i;
sum=0;
for(i=100;i<=200;i++)
{
if(0==i%3 && 0==i%7)
sum+=sqrt(i);
}
printf("%f\n",sum);
}