首页 > 代码库 > C语言第三次作业

C语言第三次作业

#include<stdio.h>int main(void){    printf("* * * * * * * * * *\n");    printf(" * * * * * * * * *\n");    printf("  * * * * * * * *\n");    printf("   * * * * * * *\n");    printf("    * * * * * *\n");    printf("     * * * * *\n");    printf("      * * * *\n");    printf("       * * *\n");    printf("        * *\n");    printf("         *\n");}
#include<stdio.h>int main(void){    printf("*\n");    printf("**\n");    printf("***\n");    printf("****\n");    printf("*****\n");    printf("******\n");    printf("*******\n");    printf("********\n");    printf("*********\n");    printf("**********\n");}
#include<stdio.h>int main(void){    printf("* * * * * * * * * *\n");    printf("* * * * * * * * * *\n");    printf("* * * * * * * * * *\n");    printf("* * * * * * * * * *\n");    printf("* * * * * * * * * *\n");    printf("* * * * * * * * * *\n");    printf("* * * * * * * * * *\n");    printf("* * * * * * * * * *\n");}

整数152的各位数

#include<stdio.h>int main(){    int a,b,c,d;     a=152;     b=a%10;     c=(a-b)%100/10;     d=a/100;    printf("%d %d %d",b,c,d);}

自由落体

#include<stdio.h>int main(){    int t=3;    int g=10;    int height;    height=0.5*g*t*t;    printf("%d",height);}

存款利息

#include<stdio.h>int main(){    int money;    int year;    int rate;    double interest;    printf("请输入money year rate的值");    scanf("%d %d %d",money,year,rate);    interest=money*(1+rate,year)-money;    printf("%f",interest);         } 

电费

#include<stdio.h>#include<math.h>int main(){    double x;    double cost;    printf("请输入x的值");    scanf("%lf",&x);    if(x>0&&x<=50)       printf("cost=%f",cost=0.53*x);    else if(x>50)       printf("cost=%f",cost= 50*0.53+(x-50)*0.58);    else       printf("Invalid Value!"); } 

分段函数1

#include<stdio.h>int main(){   int x;   double y;   printf("请输出x的值");   scanf("%d",&x);   if (x==0)           y=0;    else        y=1/(double)x;        printf("%f",y);}

分段函数2

#include<stdio.h>#include<math.h>int main(){   double x;   double y;   scanf("%lf",&x);   if (x>=0)           y=sqrt(x);    else        y=pow(x+1,2)+2*x+1/x;        printf("f(x)=%f",y);}

A,B,C,D,E的等级

#include<stdio.h>int main(){    char score;    scanf("%c",&score);//A,B,C,D,E    switch(score)    {        caseA:          printf("90~100");          break;        caseB:          printf("80~89");          break;        caseC:          printf("70~79");          break;        caseD:          printf("60~69");          break;        caseE:          printf("0~59");          break;        default:          printf("输入有误");                }} 

 

C语言第三次作业