• 例3-8+3-9


    #include<stdio.h>
    int main(void)
    {
        int choice,i;
        double price;
    
        for(i=1;i<=5;i++){
            printf("[1]Select crisps
    ");
            printf("[2]Select popcorn
    ");
            printf("[3]Select chocolate
    ");
            printf("[4]Select cola
    ");
            printf("[0]exit
    ");
    
            printf("Enter choice:");
            scanf("%d",&choice);
    
            if(choice==0)
                break;
    
            switch(choice){
                case 1:price=3.0;break;
                case 2:price=2.5;break;
                case 3:price=4.0;break;
                case 4:price=3.5;break;
                default:price=0.0;break;
            }
            printf("price=%0.1f
    ",price);
        }
        printf("Thanks
    ");
    
        return 0;
    }

    #include<stdio.h>
    int main(void)
    {
        double value1,value2;
        char op;
    
        printf("Type in an  expression:");
        scanf("%lf%c%lf",&value1,&op,&value2);
        switch(op){
        case'+':
            printf("=%.2f
    ",value1+value2);
            break;
        case'-':
            printf("=%.2f
    ",value1-value2);
            break;
        case'*':
            printf("=%.2f
    ",value1*value2);
            break;
        case'/':
            printf("=%.2f
    ",value1/value2);
            break;
        default:
            printf("Unknown operator
    ");
            break;
        }
        return 0;
    }

  • 相关阅读:
    bzoj4033
    bzoj 1197
    bzoj 1196
    bzoj 1195
    bzoj 1194
    bzoj 1193
    bzoj 1192
    jvm系列(一):java类的加载机制
    红黑树之 原理和算法详细介绍
    TreeMap详细介绍(源码解析)和使用示例
  • 原文地址:https://www.cnblogs.com/xuqiongxiang/p/3350179.html
Copyright © 2020-2023  润新知