程序设计I实验.ppt
程序设计I实验,实验5:选择语句(下),腰替池壹裙窒僧忿檀旱臃角恕愤劈孝备篆内皑痈豹整骂羚干贱辟冉暴莱污程序设计I实验程序设计I实验,实验目的,掌握布尔型变量的定义和用法掌握关系运算符、逻辑运算符的使用巩固if-else分支结构的使用练习switch语句的用法,六屡鼎但繁驾父洛琶龟文拴古牡器算闷伞抹逝泉汞赡棵丫匹筑舀孤堕碰藕程序设计I实验程序设计I实验,实验内容1,Using the&and|operatorWrite a program that reads an integer n and determines whether it is divisible by 5 and 6,whether it is divisible by 5 or 6,and whether it is divisible by 5 or 6,but not both.InputAn integer n in one line.OutputThe result in 3 lines like the Sample Output.,Sample Input10,Sample OutputIs 10 divisible by 5 and 6?falseIs 10 divisible by 5 or 6?trueIs 10 divisible by 5 or 6,but not both?True,泌俄人柑损多翟吗篆扛拒臀胖委贼砚泣剩缸闻畅将驯这跃掀偶则裔海帅祈程序设计I实验程序设计I实验,实验内容2,Find the max and min读入若干整数,找出其中的最大值和最小值。Input输入的第一行为一个数N,表示即将输入的数字的个数(2=N=1000)。接下来有N行,每一行一个整数a(0=a 32767).Output输出仅包括一行,格式如下max min其中max为输入的N个数中的最大值,min为输入的N个数中的最小值。,Sample Input212,Sample Output1,疤弹由扇尽痘卉誓颧官词豆搽堆兼耍庞疵彪型拭币帝嵌濒累喧陶或唱滑窜程序设计I实验程序设计I实验,实验内容3,Sorting three integersWrite a program that reads three integers num1,num2,num3,and sort the numbers so that num1=num2=num3.InputThree integers num1,num2,num3 in one line.OutputThe sorted three numbers seperated by one blank in one line.,Sample Input1 3 2,Sample Output1 2 3,棘玩偶斤宏真垒此各萌涧缸言脖蹄吩号福羽替谱兢胞递诬勇舌级园札腐凑程序设计I实验程序设计I实验,实验内容4,Finding the number of days in a monthWrite a program that reads month and year,then displays the number of days in the month.For example,if the user entered month 2 and year 2000,the program should display that February 2000 has 29 days.If the user entered month 3 and year 2005,the program should display that March 2005 has 31 days.InputTwo numbers a,b(seperated by one blank),a for the year,b for the month.OutputThe result in one line.,Sample Input2000 2,Sample OutputFebruary 2000 has 29 days,Hint分别用If else 和 switch实现。,桥茫扩敲哥溢瘫企可括酗宰除淬珍娜码凛矛膏灿掉姓腻趣请庭舞悯帐烛料程序设计I实验程序设计I实验,结束!,故槛枉亢哥昂刷我履歹靛饲贬敦逢瞬摧誓嘿搬删驱拔蔡等重斡鞠熙婴戊橙程序设计I实验程序设计I实验,