抄写例题作业1

Posted 少恭寻

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了抄写例题作业1相关的知识,希望对你有一定的参考价值。

#include<stdio.h> 
#define PI 3.1415926
int main()
{
    float l,s,r,v;
    printf("input radius:");
    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);
}
结果如下:
input radius:4
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
请按任意键继续. . .

 

以上是关于抄写例题作业1的主要内容,如果未能解决你的问题,请参考以下文章

抄写例题作业1

抄写例题作业1

抄写例题作业1

抄写例题作业1

抄写例题作业1

抄写例题作业1