资源描述
上机实验3:选择结构程序设计,1.【3.3】统计各类字符个数输入10个字符,统计其中英文字母、空格或回车、数字字符和其他字符的个数。【输入输出样例】(下划线部分为输入,表示空格)Input10characters:Reold123?letter=5,blank=1,digit=3,other=1(filename:cp31.c),2.【3.5】【3.三】(filename:cp32.c)查询水果单价有4种水果,苹果(apple),梨(pear),橘子(orange)和葡萄(grape),单价分别为3.00元/千克,2.50元/千克,4.10元/千克和10.20元/千克。在屏幕上显示以下菜单(编号和选项),用户可以连续查询水果的单价,当查询次数超过5次时,自动退出查询;不到5次时,用户可以选择退出。当用户输入编号14,显示相应水果的单价(保留1位小数);输入0,退出查询;输入04之外的其他编号,显示价格为0。,【输入输出样例】(表示空格)1apples2pears3oranges4grapes0exitEnterchoice:11applesprice=3.0Enterchoice:5otherprice=0.0Enterchoice:44grapesprice=10.2Enterchoice:0Thanks,3.【3.三】(filename:cp33.c)能否被3,5,7整除输入一个整数x,判断x能否被3,5,7整除,并输出以下信息之一:xcanbedivisibleby3,5,7.即能同时被3,5,7整除;xcanbedivisibleby?,?.(其中?为3,5,7之一)即能被其中两个数(要指出哪两个)整除;xcanbedivisibleby?.(其中?为3,5,7之一)即能被其中一个数(要指出哪一个)整除;xcannotbedivisibleby3,5,7.即不能被3,5,7任一个整除。,【输入输出样例1】Enterx:441xcanbedivisibleby3,7.【输入输出样例2】Enterx:1024xcannotbedivisibleby3,5,7.,4.【3.8】【3.三】(filename:cp34.c)计算个人所得税2011年开始实行新个人所得税法,要求输入月薪salary,输出应交的个人所得税tax(保留两位小数)。新税法方案如下:tax=rate*(salary-3500)-deduction当salary=3500时,rate=0、deduction=0;当3500salary=5000时,rate=3%、deduction=0;当5000salary=8000时,rate=10%、deduction=105;当8000salary=12500时,rate=20%、deduction=555;当12500salary=38500时,rate=25%、deduction=1005;当38500salary=58500时,rate=30%、deduction=2755;当58500salary=83500时,rate=35%、deduction=5505;当83500salary时,rate=45%、deduction=13505;,【输入输出样例1】(表示空格)Enterthesalary:5010.87tax=46.09【输入输出样例2】Enterthesalary:32098.76tax=6144.69【输入输出样例3】Enterthesalary:3000tax=0.00【输入输出样例4】Enterthesalary:59000tax=13920.00【输入输出样例5】Enterthesalary:84500tax=22945.00,5.【3.9】【3.三】(filename:cp35.c)百分制成绩转五级制并统计各级成绩个数输入一个正整数n,再输入n个学生的成绩,统计各等级成绩的个数。成绩等级分为五级,分别为A(90-100)、B(80-89)、C(70-79)、D(60-69)和E(0-59)。【输入输出样例】(表示空格)Entern:5Entergrade1:77Entergrade2:54Entergrade3:92Entergrade4:73Entergrade5:60,(接左)ThenumberofA(90100):1ThenumberofB(8089):0ThenumberofC(7079):2ThenumberofD(6069):1ThenumberofE(059):1,6.闰年、季节和月天数输入年份和月份,判断输出该年是否是闰年,并根据月份判断输出是什么季节和该月有多少天。闰年(Leapyear)的条件是符合下面两条件之一:年份能被4整除,但不能被100整除;年份能被400整除。季节规定为:35月为春季(Spring),68月为夏季(Summer),911月为秋季(Fall),122月为冬季(Winter)。,【输入输出样例1】20093Commonyear,Spring,31【输入输出样例2】20082Leapyear,Winter,29(filename:cp36.c),结束,
展开阅读全文