首页 > 代码库 > 第三次作业

第三次作业

1,

#include<stdio.h>int main()//十行三角形 {    printf("*\n");    printf("* *\n");    printf("* * *\n");    printf("* * * *\n");    printf("* * * * *\n");    printf("* * * * * *\n");    printf("* * * * * * *\n");    printf("* * * * * * * *\n");    printf("* * * * * * * * *\n");    printf("* * * * * * * * * *\n");    return 0;}

2,

#include<stdio.h>int main()//10×10矩形 {    printf("* * * * * * * * * *\n");    printf("* * * * * * * * * *\n");    printf("* * * * * * * * * *\n");    printf("* * * * * * * * * *\n");    printf("* * * * * * * * * *\n");    printf("* * * * * * * * * *\n");    printf("* * * * * * * * * *\n");    printf("* * * * * * * * * *\n");    printf("* * * * * * * * * *\n");    printf("* * * * * * * * * *\n");    return 0;}

3,

#include<stdio.h>int main()//十行倒三角型形 {    printf("* * * * * * * * * *\n");    printf(" * * * * * * * * *\n");    printf("  * * * * * * * *\n");    printf("   * * * * * * *\n");    printf("    * * * * * *\n");    printf("     * * * * *\n");    printf("      * * * *\n");    printf("       * * *\n");    printf("        * *\n");    printf("         *\n");    return 0;}

4,

#include<stdio.h>int main()//五级制成绩(A~E),输出相应的百分制成绩(0~100)区间{    char score;    scanf("%c",&score);    switch (score)    {        case A:            printf("90~100");            break;        case B:            printf("80~89");            break;        case C:            printf("70~79");            break;        case D:            printf("60~69");            break;        case E:            printf("0~59");            break;    }    return 0;}

5,

#include<stdio.h>int main()//华氏温度转换摄氏温度 {    int C;    int F;    printf("输入华氏温度: ");     scanf("%d",&F);        C=5*(F-32)/9;    printf("%d",C);    return 0;}

6,

#include<stdio.h>#include<math.h>int main()//100米自由落体{    int g=10,t=3;    double h;                h=0.5*g*pow(t,2);    printf("%f\n",h);    return 0;}

7,

#include<stdio.h>int main()//输出整数152的个位数字、十位数字和百位数字的值{    int a;    scanf("%d",&a);    while(a!=0)    {        printf("%d\n",a%10);        a=a/10;    }    return 0;}

8,

#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);    return 0;}

9,

#include<stdio.h>#include<math.h>int main()//计算存款利息 {    int money,year;    double rate,interest;    printf("输入存款金额: ");    scanf("%d",&money);    printf("输入存期: ");    scanf("%d",&year);    printf("输入年利率: ");    scanf("%lf",&rate);    interest=money*pow(1+rate,year)-money;    printf("interest=%f\n",interest);    return 0;}

10,

#include <stdio.h>int main()//阶梯电价{   int c ;   double f;   scanf("%d",&c);   if(c<=50)     {f=0.53*c;}   else     {f=50*0.53+(c-50)*0.05;}   printf("费用为:%lf",f);   return 0;}

 



第三次作业