background image

作业一

1、 求一个任意边长的矩形面积。
#include <stdio.h>
void main()
{int w,h,sum;
scanf("%d%d",&w,&h);
sum=w*h;
printf("area=%d\n",sum);
}
2、 求一个任意半径的圆的面积及周长。
#define PI 3.14159
#include <stdio.h>
void main()
{float r,area,c;
scanf("%f",&r);
area=PI*r*r;
c=2*PI*r;
printf("area=%f\ncircle=%f\n",area,c);
}
3、 已知:w=5, y=4, z=2, 求表达式:w*y/z 的值,并输出。
##include <stdio.h>
void main()
{  int w,y,z,r;

   w=5;
   y=4;
   z=2;
   r=w*y/z;
    printf("%5d",r);
}

作业二

1、 从键盘上输入三个数,求出其中的最大值,并输出。
#include <stdio.h>
void main()
{int a,b,c,max;
scanf("%d%d%d",&a,&b,&c);
max=a;
if(max<b) max=b;
if(max<c) max=c;
printf("max=%d\n",max);
}
2、 求 sin30

0。

+sin60

0

+cos30

0

+cos60

0

之和。(注意:30*3.14159/180)