作业1:
C语言标准库的目的:将常用的函数编完放到一个文件里,供编程人员使用,使编程更加的方便,极大地方便了用户,同时也补充了C语言本身的不足。
我的程序:
#include "stdafx.h"
#include"math.h"
void main()
{
float a=1,b=2,c;
c=cos(a+b);
printf("cos(1+2)=%f\n",c);
}
1_2
我的程序:
float chufa(int a,int b,int c)
{float d;
d=(float)a/(b+c);
return d;
}
void main ()
{int x=234,y=1,z=257;
float h;
h=chufa(x,y,z);
printf("234/(1+257)=%f\n",h);
int x=1065,y=24,z=13;
h=chufa(x,y,z);
printf("1065/(24+13)=%f\n",h);
return ;
}
1_3:
我的程序:
#include "stdafx.h"
#include "math.h"
#define PI 3.1415926
void main ()
{
float a,b;
a=2*PI-1;
b=log(sqrt(a))/log(5.f);
float c,d;
c=PI+1;
d=exp(sqrt(c));
printf("%f\n%f\n",b,d);
return ;
}
作业2:
我的程序:
#include "stdafx.h"
void main()
{int a;
while(1)
{
printf("请输入数字");
scanf_s("%d",&a);
if (a<20)
printf("你输入的数字小于20\n");
else
printf("你输入的数字大于20\n");
}
}
作业3_1:属于第二个IF
作业3_2:
修改后程序:
if (x > 0)
{
if (y > 1)
z = 1;
else
z = 2;
}
作业4:
原程序:
#include "stdafx.h"
void main()
{
int a ;
a=1;
while (a<=5)
{printf("%d\n",a);
a++;
}
}
修改后程序:
#include "stdafx.h"
void main()
{
int a ;
for(a=1;a<=5;a++)
{printf("%d\n",a);
}
}
作业5_1:
我的程序:
#include "stdafx.h"
#define PI 3.1415926
#include "math.h"
void main()
{
float a , b ,c,d;
printf ("请输入两个半径:\n");
scanf_s ("%f %f",&a,&b);
c=PI*(pow(a,2));
d=PI*(pow(b,2));
printf ("两个圆的面积分别为:%f %f\n",c,d);
}
作业5_1:
将程序修改成如下即可:
#include "stdafx.h"
#include "math.h"
int main ()
{
printf("%f\n", sin(1.f) + sin(1/2.f) + sin(1/3.f) + sin (1/4.f) );
return 0;
}
作业6:
我的程序:
#include "stdafx.h"
#include "math.h"
void main()
{
float a,b,c,d;
int e=0;
while (e<4)
{
printf ("请输入第%d组三角形的参数:",e);
scanf_s ("%f %f %f",&a,&b,&c);
printf ("第%d组三角形的实参为:%f %f %f\n",e,a,b,c);
d=2.5 * 4.1 * sin( 32/180.0 * 3.14 )/2.0 ;
printf ("第%d组三角形的面积为:%f\n",e,d);
printf ("————————分割线————————\n");
e++;
}
}
作业7:
作者大学的经历是很多人都有过的,而我们现在正处在活跃的对未来充满向往的大一阶段,看了这个博文,我想了很多,既然有了别人的前车之鉴,那就要作为自己的后车之师,过去无法弥补,至少在以后的阶段,能够看清自己的方向。我电脑里的游戏早就卸载了,以后还有很长的路要走。