您的位置:首页 > 其它

第五堂课后作业

2013-04-06 21:16 239 查看
[b]作业1.1:C语言标准库的目的是什么?[/b]

答:C语言的库函数并不是C语言本身的一部分,它是由编译程序根据一般用户的需要编制并提供用户使用的一组程序。

我的程序:

#include "stdafx.h"
void main()
{
printf("在主函数前加入#include<math.h>\n");
printf("表示输入的是数字函数\n");
}

其运行结果截图:



 

作业1.2:用一个程序计算下面两个表达式的值;


.

其程序如下:

#include "stdafx.h"
void main()
{
float a=234,b=1,c=257,d;
d=(a/(b+c));
printf("(1)%f\n",d);
float e=1065,f=24,g=13,h;
h=(e/(f+g));
printf("(2)%f\n",h);
}


其运行结果截图:



作业1.3:利用C标准库里的数学函数<math.h>,用一个程序计算下面两个表达式的值;



我的程序:

#include "stdafx.h"
#include <math.h>;
void main()
{
float a,b;
a=log(sqrt(2*3.14-1))/log(5.0);
b=pow(2.718,sqrt(3.14+1));
printf("(1)%f\n(2)%f\n",a,b);
}

其运行结果截图:

任务2:

 

#include "stdafx.h"
int main()
{
int a,b,c;
scanf_s("%d",&a);
if(a>0)
{
for(c=1,b=0;c<=100;c++)
b=b+c;
printf("sum=%d\n",b);
}
if(a<=0)
printf("a=0\n");
}


其运行结果截图:





 任务3;

作业3.1:

else属于第二个if,因为在c语言中else属于离其最近的if中

作业3.2:

要讲嵌套的语句放在{ }内

任务4:

其程序为:

#include"stdafx.h"
void main()
{
int a,b,c,d;
a=1,b=0;
while(a<=10)
{
b=b+a;
a++;
}
printf("sum1=%d\n",b);
for(c=1,d=0;c<=10;c++)
d=d+c;
printf("sum2=%d\n",d);
}

其运行结果截图:



 

 任务5:

其运行程序为:



#include"stdafx.h"
int main()
{
float r1,r2,s1,s2;
printf("输入圆的半径:\n");
scanf_s("%f%f",&r1,&r2);
s1=3.14*r1*r1;
s2=3.14*r2*r2;
printf("s1=%f\ns2=%f\n",s1,s2);
}


其运行结果截图:



5.2

因为程序返回值为0,所以输出结果错误

任务6:

#include "stdafx.h"
#include <math.h>
int main ()
{
float area(float x,float y,float z);
float a,b, c;
for(int i=0;i<5;i++)
{
printf("请输入第%d组三角形的参数:",i);
scanf_s("%f%f%f",&a,&b,&c);
printf("第%d组三角形的实参为,a边长%.2f;b边长%.2f;夹角%.2f\n",i,a,b,c);
printf("第%d组三角形面积为%.2f\n",i,area(a,b,c));
}

}
float area (float x,float y,float z)
{
return (float)x*y*sin(z/180.0*3.14)/2.0;
}

其运行结果截图:



任务7:

每个人生命中都会或多或少得到或失去一些东西,而只有在后来的过程中才会发现这些东西的重要性,所以我们所能做的就是珍惜现在身边的所有,并勇敢去尝试并发现新的值得我们所要守护的东西。

 

 

 

 

 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: