哪位C语言高手帮我看下

[复制链接]
查看11 | 回复2 | 2011-8-19 07:19:59 | 显示全部楼层 |阅读模式
写一个简单的计算机器,做二元运算-*/和%运算,运算完成后可以让用户选择输入y或者Y,以重复执行前面的运算,输入N或者n结束程序我所编写的代码如下:#includestdio.hintmain(void){doublenumber1=0.0;doublenumber2=0.0;charoperation=0;charanswer=0;there:printf(\"\\nPleaseinputthejisuanshuju:\\n\");scanf(\"%lf%c%lf\",switch(operation){case\'\':printf(\"=%lf\\n\",number1number2);break;case\'-\':printf(\"=%lf\\n\",number1-number2);break;case\'*\':printf(\"=%lf\\n\",number1*number2);break;case\'/\':if(number2==0)printf(\"\\n\\nbeichushubunengwei0!\\n\");elseprintf(\"=%lf\\n\",number1/number2);break;case\'%\':if((long)number2==0)printf(\"\\n\\nbeichushubunengwei0!\\n\");elseprintf(\"=%ld\\n\",(long)number1%(long)number2);break;default:printf(\"\\n\\ninvalidshuju!\\n\");printf(\"\\n\\nPleaseinputtheshujuonceagain:\\n\");}printf(\"\\nwewillcontinuetotheprograme,pressYyorNn:\");scanf(\"%c\",if(answer==\'Y\'||answer==\'y\')gotothere;elseif(answer==\'N\'||answer==\'n\')printf(\"wewillendtheprograme\");return0;}这行代码编译可以通过并生成EXE文件,但是运行的时候并没有按照我原先的意图运行起来,请问代码到底在哪里出了问题
回复

使用道具 举报

千问 | 2011-8-19 07:19:59 | 显示全部楼层
Pleaseinputthejisuanshuju:12=3.000000wewillcontinuetotheprograme,pressYyorNn:yPleaseinputthejisuanshuju:23=5.000000wewillcontinuetotheprograme,pressYyorNn:nwewillendtheprogramePressanykeytocontinueprintf(\"\\nwewillcontinuetotheprograme,pressYyorNn:\");getchar();加个getchar();scanf(\"%c\",
回复

使用道具 举报

千问 | 2011-8-19 07:19:59 | 显示全部楼层
你是不是没加getch();
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行