# 抄写例题作业1

#include<stdio.h>
#define PI 3.1415926
int main()
{
float l,s,r,v;
scanf("%f",&r);
l=2.0*PI*r;
s=PI*r*r;
v=4.0/3*PI*r*r*r;
printf("l=%10.4f\ns=%10.4f\nv=%10.4f\n",l,s,v);
}

l=   25.1327
s=   50.2655
v=  268.0826

--------------------------------
Process exited after 2.399 seconds with return value 0

#include<stdio.h>
#define R 3.0
#define PI 3.1415926
#define L 2*PI*R
#define S PI*R*R
int main()
{
printf("L=%f\nS=%f\n",L,S);
}

L=18.849556
S=28.274333

--------------------------------
Process exited after 0.01662 seconds with return value 0

#include<stdio.h>
#define PI 3.1415926
#define S(r) PI*r*r
int main()
{
float a,area;
a=3.6;
area=S(a);
printf("r=%f\narea=%f\n",a,area);
}

r=3.600000
area=40.715038

--------------------------------
Process exited after 0.01604 seconds with return value 0

#include<stdio.h>
#define PI 3.1415926
#define CIRCLE(R,L,S,V) L=2*PI*R;S=PI*R*R;V=4.0/3.0*PI*R*R*R
int main()
{
float r,l,s,v;
scanf("%f",&r);
CIRCLE(r,l,s,v);
printf("r=%6.2f,l=%6.2f,s=%6.2f,v=%6.2f\n",r,l,s,v);
}

4
r=  4.00,l= 25.13,s= 50.27,v=268.08

--------------------------------
Process exited after 1.731 seconds with return value 0

#include<stdio.h>
#define PR printf
#define NL "\n"
#define D "%d"
#define D1 D NL
#define D2 D D  NL
#define D3 D D D NL
#define D4 D D D D NL
#define S "%s"
int main()
{
int a,b,c,d;
char string[]="CHINA";
a=1;b=2;c=3;d=4;
PR(D1,a);
PR(D2,a,b);
PR(D3,a,b,c);
PR(D4,a,b,c,d);
PR(S,string);
}

1
12
123
1234
CHINA
--------------------------------
Process exited after 0.01793 seconds with return value 0

#include<stdio.h>
#define LETTER 1
int main()
{
char str[20]="C Language",c;
int i;
i=0;
while((c=str[i])!='\0')
{
i++;
#if LETTER
if(c>='a'&&c<='z')
c=c-32;
#else
if(c>='A'&&c<='Z')
c=c+32;
#endif
printf("%c",c);
}
printf("\n");
}

C LANGUAGE

--------------------------------
Process exited after 0.01819 seconds with return value 0

posted on 2017-04-09 16:09  少恭寻  阅读(182)  评论(0编辑  收藏  举报