freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

programminginansic-chapter5decisionmakingand-wenkub

2023-04-17 00:09:57 本頁(yè)面
 

【正文】 ? Input 2 real numbers, and output them in ascending order. ? Step1: Read 2 real numbers into variable x and y. ? Step2: If x is greater than y, exchange them. ? Step3: Output x and y. x y exchange x and y true false output x and y 4/17/2023 11 if Statement – Program 1 main() { float x, y, temp。 y=x。 else printf ( “ Wrong )。E39。C39。A39。 else if ( exp2 ) s2。 else statement 2。Chapter 5 Decision Making and Branching PROGRAMMING IN ANSI C 2 Question ? Questions: ? How do we judge whether a student pass an examination according to his score? ? How do we decide his grade according to his score? ? In human nature language: If…, then… ? In C: Decisionmaking statement (branch statement) 4/17/2023 3 Chapter 5 ? In this chapter, we will learn: ? Decisionmaking statement: if ? Conditional operator: ? : ? Multiway decisionmaking statement: switch ? Assisted control statement: break 4/17/2023 4 3 Forms of if Statement ? Form 1 – the most simple form if ( test expression ) statement。 if ( score = 60 ) printf(He passed this examination!)。 else …… else if ( expn ) sn。 else if ( score = 80 ) grade = 39。 else if ( score = 60) grade = 39。 4/17/2023 7 if Statement ? The value of the test expression may be any type. If it equals zero, it is false, otherwise true. if ( a==b x==y ) printf ( a=b, x=y )。 = 0“if Statement ? The value of the test expression may be any type. If it equals zero, it is false, otherwise true. 2 Wrong 4/17/2023 9 if Statement ? The statement following if or else may be a single statement or a pound statement. main() { int x, y。 else x++。 printf (Please input 2 numbers:\n)。 y = temp。 scanf ( %f %f, x, y)。 } 4/17/2023 14 if Statement – Program 1 ? Programming Exercises : Input 3 real numbers, and output them in ascending order. (Homework!) 4/17/2023 15 if Statement – Program 2 ? Read in one year, and judge whether it is a leap year or not. ? Step1: Read in the year. ? Step2: If the test expression (year%4==0 year%100!=0)||(year%400==0) is true, then output it is a leap year, or else output it isn’ t a leap year. 4/17/2023 16 if Statement – Program 2 main() { int year。 else printf ( %d is not a leap year!\n, year )。 if ( (year%4==0year%100!=0)||(year%400==0) ) isLeap = 1。039。a39。A39。 printf (Please input the character:\n)。 ch = 39。a39。A39。 else printf(%c is an other character!,ch)。 else statement4。 } else statement2。 4/17/2023 24 if Statement – Program 4 main() { float score。 else if ( score = 60 ) printf ( The grade is: B!\n )。 printf ( Please input the score:\n )。 else if ( score = 60 ) grade = 39。 printf ( The grade is: %c!\n, grade )。 scanf ( %f, score )。B39。 } 4/17/2023 27 if Statement – Program 4 main() { float score。 if ( score 100 || score 0 ) printf( The score is wrong!\n )。B39。 } } 4/17/2023 28 Conditional Operator ? : ? Ternary operator: conditional exp ? exp1 : exp2 conditional exp return the value of exp1 true(not 0) false(0) return the value of exp2 4/17/2023 29 Conditional Operator ? : ? Ternary operator: conditional exp ? exp1 : exp2 if ( a b ) max = a。 else printf(%d, b)。 printf( %f, b 0 ? a + b : a – b )。 : 39。 scanf ( %c, ch )。Z39。A39。 printf ( The charactor is: %c\n, ( ch = 39。 ) ? ch + 32 : ch )。 default: statement group。 …… statement groupn。 case 39。C39。: printf(Fail!)。 39。 default case “ Good!” “ Pass!” “ Data error” “ Fail!” 39。 Good!Pass!Fail!Data error! 4/17/2023 38 switch Statement ? According to the grade, output information. ? Grade A: output Excellent!. ? Grade B: output Good!. ? Grade C: output Pass!. ? Grade D: output Fail!. ? Others: output Data error! switch ( grade ) { case 39。B39。: printf(Pass!)。 default: printf(Data error!)。B39。D39。 break。 case value2: statemen
點(diǎn)擊復(fù)制文檔內(nèi)容
教學(xué)課件相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖片鄂ICP備17016276號(hào)-1