比着葫芦画瓢

来源:互联网 发布:东莞网络电视剧 编辑:程序博客网 时间:2024/06/10 00:54


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
    int t;
    float x,y;
    scanf("%f",&x);
    t=(x<2)+(x<6)+(x<10);
    switch(t)
    {
        case 3:y=x;break;
        case 2:y=x*x+1;break;
        case 1:y=sqrt(x+1);break;
        case 0:y=1/(x+1);break;
    }
    printf("%f",y);
    return 0;
}



#include <stdio.h>
#include <stdlib.h>

int main()
{
    int c,s;
    float p,w,d,f;
    printf("please enter p,w,s:");
    scanf("%f%f%d",&p,&w,&s);
    if (s>=3000)
        c=12;
    else
        c=s/250;
    switch(c)
    {
        case 0:d=0;break;
        case 1:d=2;break;
        case 2:
        case 3:d=5;break;
        case 4:
        case 5:
        case 6:
        case 7:d=8;break;
        case 8:
        case 9:
        case 10:
        case 11:d=10;break;
        case 12:d=15;break;
    }
f=p*w*s*(1-d/100.0);
printf("freight=%.2f\n",f);
return 0;
}



#include <stdio.h>
#include <stdlib.h>

int main()
{
    int x,y;
    scanf("%d",&x);
    y=(x>0)?x:-x;
    printf("%d",y);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    double x;
    scanf("%lf",&x);
    printf("%lf",(x>0)?x:-x);
    return 0;
}






0 0
原创粉丝点击