第三章8

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

posted @ 2013-10-05 13:02  执于一念  阅读(75)  评论(0编辑  收藏  举报