| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 411 人关注过本帖
标题:为什么运行不了
取消只看楼主 加入收藏
Justinlong
Rank: 2
等 级:论坛游民
帖 子:19
专家分:13
注 册:2012-3-13
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:1 
为什么运行不了
最近作业有一题是编简易运算器的,可我看来看去都发现不了问题,高手们帮忙找出问题来!!
#include<stdio.h>
#include<process.h>
int main()
{
    char op,ch;
    double a,b,c;
    while(1)
    {
        system("cls");
        printf("**********欢迎使用建议运算系统**********\n");
        printf("              1.加法.\n");
        printf("              2.减法.\n");
        printf("              3.乘法.\n");
        printf("              4.除法.\n");
        printf("              0.退出.\n");
        printf("****************************************\n");
        printf("请输入运算代码:\n");
        scanf("%c",&op);
        while(1)
        {
            if(op>=48&&op<=52)
                break;
            else
            {
                printf("输入错误,请重新输入:");
                scanf("%c",&op);
            }
        }
        switch(op)
        {
        case '1':
            {
                printf("请输入两个数:\n");
                scanf("%lf%lf",&a,&b);
                c=a+b;
                printf("得数c=%lf\n",c);
                break;
            }
        case '2':
            {
                printf("请输入两个数:\n");
                scanf("%lf%lf",&a,&b);
                c=a-b;
                printf("得数c=%lf\n",c);
                break;
            }
        case '3':
            {
                printf("请输入两个数:\n");
                scanf("%lf%lf",&a,&b);
                c=a*b;
                printf("得数c=%lf\n",c);
                break;
            }
        case '4':
            {
                printf("请输入两个数:\n");
                scanf("%lf%lf",&a,&b);
                while(1)
                {
                    if(b==0)
                    {
                        printf("输入错误,请重新输入除数:\n");
                        scanf("%lf",&b);
                    }
                    else if(b!=0)
                        break;
            }
                c=a/b;
                printf("得数c=%lf\n",c);
                break;
            }
        }
        if(op=='0')
        {
            printf("谢谢使用!\n");
            break;
        }
        else if(op!='0')
        {
            printf("是否继续<y or n>:\n");
            scanf("%c",&ch);
        }
        if(ch=='y')
            continue;
        else
            break;
    }
    return 0;
}
搜索更多相关主题的帖子: double cls include system 
2012-04-05 14:08
Justinlong
Rank: 2
等 级:论坛游民
帖 子:19
专家分:13
注 册:2012-3-13
收藏
得分:0 
为什么就没人回复呢?
2012-04-05 15:30
快速回复:为什么运行不了
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024603 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved