1 / 11

上机实验 3 : 选择结构程序设计

上机实验 3 : 选择结构程序设计. 1. 【 3.3 】 《 统计各类字符个数 》 输入 10 个字符 , 统计其中英文字母、空格或回车、 数字字符和其他字符的个数。 【 输入输出样例 】( 下划线部分为输入 ,  表示空格 ) Input 10 characters:  Reold 123? letter=5,blank=1,digit=3,other=1 ( filename: cp3 1 .c ). 2. 【3.5】 【 3. 三⑷ 】 ( filename: cp3 2 .c ) 《 查询水果单价 》

elvis-young
Download Presentation

上机实验 3 : 选择结构程序设计

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 上机实验3:选择结构程序设计 1. 【3.3】《统计各类字符个数》 输入10 个字符,统计其中英文字母、空格或回车、 数字字符和其他字符的个数。 【输入输出样例】(下划线部分为输入,表示空格) Input 10 characters:Reold 123? letter=5,blank=1,digit=3,other=1 (filename: cp31.c )

  2. 2.【3.5】【3.三⑷】 (filename: cp32.c ) 《查询水果单价》 有4 种水果,苹果(apple),梨(pear),橘子(orange)和 葡萄(grape),单价分别为3.00 元/千克,2.50 元/千克, 4.10 元/千克和10.20 元/千克。在屏幕上显示以下菜 单(编号和选项),用户可以连续查询水果的单价,当 查询次数超过5 次时,自动退出查询;不到5次时,用 户可以选择退出。当用户输入编号1~4,显示相应水 果的单价(保留1 位小数);输入0,退出查询;输入0~4 之外的其他编号,显示价格为0。

  3. 【输入输出样例】(表示空格) [1] apples [2] pears [3] oranges [4] grapes [0] exit Enter choice:1 [1] apples price=3.0 Enter choice:5 other price=0.0 Enter choice:4 [4] grapes price=10.2 Enter choice:0 Thanks

  4. 3.【3.三⑵】 ( filename: cp33.c ) 《能否被3,5,7整除》 输入一个整数x,判断x能否被3,5,7整除,并输 出以下信息之一: ⑴ x can be divisible by 3,5,7. 即能同时被3,5,7整除; ⑵ x can be divisible by ?,?. (其中?为3,5,7之一) 即能被其中两个数(要指出哪两个)整除; ⑶ x can be divisible by ?. (其中?为3,5,7之一) 即能被其中一个数(要指出哪一个)整除; ⑷ x can not be divisible by 3,5,7. 即不能被3,5,7任一个整除。

  5. 【输入输出样例1】 Enter x:441 x can be divisible by 3,7. 【输入输出样例2】 Enter x:1024 x can not be divisible by 3,5,7.

  6. 4.【3.8】【3.三⑷】 ( filename: cp34.c ) 《计算个人所得税》 2011年开始实行新个人所得税法,要求输入月薪 salary,输出应交的个人所得税 tax (保留两位小数)。 新税法方案如下: tax=rate*(salary-3500) - deduction 当 salary<=3500时,rate=0、deduction=0; 当 3500<salary<=5000时,rate=3%、deduction=0; 当 5000<salary<=8000时,rate=10%、deduction=105; 当 8000<salary<=12500时,rate=20% 、deduction=555; 当 12500<salary<=38500时, rate=25% 、deduction=1005; 当 38500<salary<=58500时, rate=30% 、deduction=2755 ; 当 58500<salary<=83500时, rate=35% 、deduction=5505 ; 当 83500<salary时, rate=45% 、deduction=13505 ;

  7. 【输入输出样例1】(表示空格) Enter the salary:5010.87 tax=46.09 【输入输出样例2】 Enter the salary:32098.76 tax=6144.69 【输入输出样例3】 Enter the salary:3000 tax=0.00 【输入输出样例4】 Enter the salary:59000 tax=13920.00 【输入输出样例5】 Enter the salary:84500 tax=22945.00

  8. 5.【3.9】【3.三⑹】( filename: cp35.c ) 《百分制成绩转五级制并统计各级成绩个数》 输入一个正整数n,再输入n个学生的成绩,统计 各等级成绩的个数。成绩等级分为五级,分别为 A(90-100 )、B(80-89 )、C(70-79 )、D(60-69 )和 E(0-59 )。 【输入输出样例】(表示空格) Enter n:5 Enter grade 1:77 Enter grade 2:54 Enter grade 3:92 Enter grade 4:73 Enter grade 5:60 (接左) The number of A(90 ~100):1 The number of B(80 ~89):0 The number of C(70 ~79):2 The number of D(60 ~69):1 The number of E(0 ~59):1

  9. 6.《闰年、季节和月天数》 输入年份和月份,判断输出该年是否是闰年,并 根据月份判断输出是什么季节和该月有多少天。 闰年(Leap year)的条件是符合下面两条件之一: ⑴ 年份能被 4 整除,但不能被 100 整除; ⑵ 年份能被 400 整除。  季节规定为: 3~5月为春季(Spring),6~8月为夏季(Summer), 9~11月为秋季(Fall),12~2月为冬季(Winter)。

  10. 【输入输出样例1】 2009 3 Common year,Spring,31 【输入输出样例2】 2008 2 Leap year,Winter,29 ( filename: cp36.c )

  11. 结 束

More Related