1、作业一一、求一个任意边长的矩形面积。#include void main()int w,h,sum;scanf(“%d%d“,sum=w*h;printf(“area=%dn“,sum);二、求一个任意半径的圆的面积及周长。#define PI 3.14159#include void main()float r,area,c;scanf(“%f“,area=PI*r*r;c=2*PI*r;printf(“area=%fncircle=%fn“,area,c);三、已知:w=5, y=4, z=2, 求表达式:w*y/z 的值,并输出。#include void main() int w,y,
2、z,r;w=5;y=4;z=2;r=w*y/z;printf(“%5d“,r);作业二一、从键盘上输入三个数,求出其中的最大值,并输出。#include void main()int a,b,c,max;scanf(“%d%d%d“,max=a;if(max#define PI 3.14159#include void main()float a,b,sum;a=30*PI/180;b=60*PI/180;sum=sin(a)+sin(b)+cos(a)+cos(60);printf(“total=%fn“,sum);三、比较两个数的大小。如果 x 大于 y,则输出:xy,否则输出:xvoid
3、 main()int x,y;scanf(“%d,%d“,if(xy)printf(“xyn“);elseprintf(“xvoid main()int a,b,c,t;scanf(“%d%d%d“,if(ab) t=b;b=a;a=t;if(ac)t=a;a=c;c=t;if(bc)t=b;b=c;c=t;printf(“%3d%3d%3dn“,a,b,c);.二、求自然数 110 之和。 。#include void main()int i,sum;i=1;sum=0;while(ivoid main()int sum1=0,sum2=0,i,x;i=1;while(imain() int
4、 a;scanf(“%d“,switch(a)case 0: printf(“Sunday“);break;case 1: printf(“Monday“);break;case 2: printf(“Tuesday“);break;case 3: printf(“Wednesday“);break;case 4: printf(“Thursday“);break;case 5: printf(“Friday“);break;case 6: printf(“saturday“);break;default: printf(“I am sorry.You are wrong.n“);.二、输入一
5、个整数,将各位数字反转后输出。如:输入 365,则输出显示为 563。#include void main()int x,r;scanf(“%d“,printf(“conver is:“);while(x!=0) r=x%10;printf(“%d“,r);x=x/10;printf(“n“);三、输入一个整数,求出它的所有因子。#include void main()int x,i;scanf(“%d“,for(i=1;i#include void main()int j=0,x,n,i;for(x=100;xn)printf(“%5d“,x);j+;if(j%5=0)printf(“n“)
6、;二、编程输出三角形的 99 乘法表。#include void main()int i,j;for(i=1;imain() int a,b,m,n,q;scanf(“%d%d“,a=m; b=n;if(ab) int z;z=a;a=b;b=z;do q=b%a;b=a;a=q;while(q!=0);printf(“%dn“,b);作业六一、利用循环语句求 (直到第 100 项的和)。127153n#include void main() int i,t=1;float s=1,p=0,n=1;for(i=1;ivoid main() int x,y=0,n,i;for(n=1;n#inc
7、lude void main() float n=1,t=1,pi=0,s=1,x,i=1;scanf(“%f“,while(fabs(t)=1e-6) pi+=t;n=n*i*(i+1);s=-s*x*x;i+;t=s/n;printf(“%f“,pi);作业七一、用选择法对 10 个整数排序(由大到小) 。#include void main(void) int a10,i,j,t;for(i=0;iaj+1) t=aj;aj=aj+1;aj+1=t;for(i=0;ivoid main(void) int i,count=0;float score10,percent;for(i=0;i
8、void main() int a33,b33,i,j;for(i=0;i#include void main() char a80,k;int i,j;gets(a);for(i=0,j=strlen(a)-1;ivoid main() int i,a=0,b=0,c=0,d=0,e=0;char q20;gets(q);for(i=0;qi!=0;i+) if(qi=0int i,j,k;for(i=0;ichar change (char a) int i;for(i=0;ai!=0;i+)if(ai=afor(i=1;iint num(int a23, int n,int m) int sum=0,i,j;for(i=0;i#include void main( )int i,sum=0;int per(int);for(i=6;i=k+1)