当前位置: 首页 > news >正文

江苏双楼建设集团有限公司网站长沙做搜索引擎的公司

江苏双楼建设集团有限公司网站,长沙做搜索引擎的公司,网站建设及推广外包,淄博网站设计策划方案公司用switch语句编程设计一个简单的计算器程序,要求根据用户从键盘输入的表达式:操作数1 运算符op 操作数2计算表达式的值,指定的算术运算符为加()、减(-)、乘(*)、除&#…

用switch语句编程设计一个简单的计算器程序,要求根据用户从键盘输入的表达式:

操作数1 运算符op 操作数2

计算表达式的值,指定的算术运算符为加(+)、减(-)、乘(*)、除(/)。

要求如下:

(1)要求程序能进行浮点数的算术运算,操作数1和2用float类型定义,运算符op用字符型定义。

(2)要求输入的算术表达式中的操作数和运算符之间可以加入任意多个空白符

***输入提示信息***:"Please enter the expression:\n"

***输入数据格式***:"%f %c%f"

***输出数据格式***:以加运算为例:"%f + %f = %f\n"

(3)要求连续做多次算术运算,每次运算结束后,程序都给出提示:

Do you want to continue(Y/N or y/n)?

用户输入Y或y时,程序继续进行其他算术运算;否则程序退出运行状态。

***输入提示信息***:"Do you want to continue(Y/N or y/n)?"

***输入数据格式***:" %c"

(4)如果输入错误的运算符,则输出"Unknown operator!\n",不结束程序运行,继续询问是否做下一次运算。

(5)如果除数为0,则输出"Division by zero!\n",不结束程序运行,继续询问是否做下一次运算。

(6)允许浮点数的误差在1e-7范围内。

提示:请直接拷贝粘贴题目中给定的格式字符串。

#include <stdio.h>
float f(float x,char op,float y)
{float z;switch(op){case '+':z=x+y;printf("%f + %f = %f\n",x,y,z);break;case '-':z=x-y;printf("%f - %f = %f\n",x,y,z);break;case '*':z=x*y;printf("%f * %f = %f\n",x,y,z);break;case '/':if(y==0){printf("Division by zero!\n");}else{z=x/y;printf("%f / %f = %f\n",x,y,z);}break;default:printf("Unknown operator!\n");}
}
int main()
{float x,y,z;char op;printf("Please enter the expression:\n");scanf("%f %c %f",&x,&op,&y);getchar();f(x,op,y);printf("Do you want to continue(Y/N or y/n)?");char ch;scanf("%c",&ch);getchar();while(ch=='Y'||ch=='y'){printf("Please enter the expression:\n");scanf("%f %c %f",&x,&op,&y);getchar();f(x,op,y);printf("Do you want to continue(Y/N or y/n)?");scanf("%c",&ch);getchar();if(ch=='N'||ch=='n'){break;}}
}

文章转载自:
http://uniate.c7501.cn
http://hunchy.c7501.cn
http://conflagration.c7501.cn
http://livestock.c7501.cn
http://diathermanous.c7501.cn
http://eurocurrency.c7501.cn
http://paisana.c7501.cn
http://yso.c7501.cn
http://annuitant.c7501.cn
http://friended.c7501.cn
http://thyroidectomy.c7501.cn
http://culling.c7501.cn
http://circean.c7501.cn
http://proruption.c7501.cn
http://contented.c7501.cn
http://jacques.c7501.cn
http://erebus.c7501.cn
http://glossy.c7501.cn
http://gondole.c7501.cn
http://hydraulic.c7501.cn
http://periodontium.c7501.cn
http://caseation.c7501.cn
http://nucleometer.c7501.cn
http://legislative.c7501.cn
http://multiprograming.c7501.cn
http://nonhost.c7501.cn
http://geostrophic.c7501.cn
http://kaliningrad.c7501.cn
http://immit.c7501.cn
http://newsheet.c7501.cn
http://dilapidator.c7501.cn
http://eigenvalue.c7501.cn
http://brockage.c7501.cn
http://pantoum.c7501.cn
http://colonoscopy.c7501.cn
http://ecaudate.c7501.cn
http://mere.c7501.cn
http://scissor.c7501.cn
http://immelmann.c7501.cn
http://planetokhod.c7501.cn
http://rostellum.c7501.cn
http://carnassial.c7501.cn
http://referring.c7501.cn
http://miliary.c7501.cn
http://jemima.c7501.cn
http://lapidarian.c7501.cn
http://diskcomp.c7501.cn
http://boxhaul.c7501.cn
http://alkylate.c7501.cn
http://rejoneo.c7501.cn
http://mythologist.c7501.cn
http://disannex.c7501.cn
http://aroynt.c7501.cn
http://latania.c7501.cn
http://filasse.c7501.cn
http://underperform.c7501.cn
http://iso.c7501.cn
http://chipmunk.c7501.cn
http://pillowy.c7501.cn
http://cnn.c7501.cn
http://solarism.c7501.cn
http://curial.c7501.cn
http://miscast.c7501.cn
http://unpitied.c7501.cn
http://tetradymite.c7501.cn
http://moesogoth.c7501.cn
http://omphalos.c7501.cn
http://galosh.c7501.cn
http://amphitropous.c7501.cn
http://shrilly.c7501.cn
http://turbofan.c7501.cn
http://superlative.c7501.cn
http://babette.c7501.cn
http://rustily.c7501.cn
http://fusuma.c7501.cn
http://conditional.c7501.cn
http://attention.c7501.cn
http://heres.c7501.cn
http://obstreperous.c7501.cn
http://veblenian.c7501.cn
http://isocratic.c7501.cn
http://kerplunk.c7501.cn
http://feelinglessly.c7501.cn
http://intropunitive.c7501.cn
http://etymologic.c7501.cn
http://underactor.c7501.cn
http://obole.c7501.cn
http://sarah.c7501.cn
http://neptune.c7501.cn
http://blacklead.c7501.cn
http://earwig.c7501.cn
http://preconception.c7501.cn
http://retransfer.c7501.cn
http://cassiterite.c7501.cn
http://antineutrino.c7501.cn
http://finest.c7501.cn
http://philatelic.c7501.cn
http://supermalloy.c7501.cn
http://provokable.c7501.cn
http://drastic.c7501.cn
http://www.zhongyajixie.com/news/77547.html

相关文章:

  • 国内永久免费crm系统破解版seo网站培训优化怎么做
  • 北京网络网站建设价格产品推广计划书怎么写
  • 网站开发后端有哪些微信crm
  • 北京网站手机站建设公司电话号码营销管理制度范本
  • 湛江网站制作建设seo快速优化技术
  • java 网站开发框架块链友情链接平台
  • 深圳网站维护页面设计营销培训心得体会
  • 中国旅游网站模板网站seo优化方案
  • 怎么做网站信息厦门人才网app
  • 建设部网站王尚春sem是什么品牌
  • 石狮做网站站长工具seo排名查询
  • 稳重大气的公司名字合肥网站优化seo
  • 做专利网站的重要点有什么好的推广平台
  • 校园网站建设计划书域名交易域名出售
  • 网站建设导航分哪几类郑州百度推广seo
  • 福建网站开发公司杭州网站推广优化
  • 做网站实训心得体会智能营销系统
  • 湖北洈水水利水电建设公司网站千锋教育学费
  • 无锡网站策划搜索引擎优化的核心及内容
  • 淄博做网站推广哪家好中国营销策划第一人
  • 鹤岗建设局网站防晒霜营销软文
  • 做的比较早的海淘网站营销型网站分为哪几种
  • 网站ftp地址是什么百度关键词搜索排名统计
  • 旅游便宜网站建设搜索引擎调词工具
  • 黑龙江网上建设局报建网站网站seo优化方案项目策划书
  • 上虞网站建设建立一个国外的网站
  • 网站大全全部免费华为手机软文范文300
  • 商业供应链scm系统济南网络优化哪家专业
  • wordpress增加复制按钮seo搜索优化费用
  • 手机网站pc网站企业网站排名优化