scanf(格式控制,输入项表)(国外英文资料).docVIP

  • 7
  • 0
  • 约7.44千字
  • 约 16页
  • 2017-06-05 发布于河南
  • 举报

scanf(格式控制,输入项表)(国外英文资料).doc

scanf(格式控制,输入项表)(国外英文资料)

scanf(格式控制,输入项表) Scanf (format control, input table); Ampers-address operator Printf (format control, output table); - format character (output) : Its going to be an int Float - - - % f Double - - % f or % lf Char - - - - % c String % s Its a good thing - format character (input) : Its an int Its long Its a short one Float % lf or % le - double % s -- -strings The programming structure - the sequence structure Rounding off the middle variable 3 - - Conditional control statements: - - select control statement if or if - else switch -loop control statement -turn to the control statement - selection structure: * * * if or if - else is a single-branch choice structure The multi-branch choice structure of the * * * swtich statement Part 1: the single-branch choice structure of the if statement No elses if statement The general invocation of the if statement: If (expression) statement For example, if (a! = b) {t = a; A = b; B = t; } * * if is a key word The expression is just a valid C expression. There is only one sentence in theory, and multiple is a compound statement. -if statement execution: First calculate the value of the if post expression, and if the expression has a non-zero value, then execute the following clause. If its false, it doesnt. The simple application of the if statement: For example 1: write a function that inputs two different integers a, and b outputs the larger number of them. # include stdio, h Void main () {int a, b; Printf ( please enter variable a, b: ); Scanf (% d % d, a, b); If (a b) printf ( a = % d \ n ); If (b a) printf ( b = % d \ n , b); } Minus , a is equal to 5, and b is equal to 6 For example 2: write a function to determine whether k is odd or even. # include stdio, h Void main () {int k; Printf ( please enter the value of the variable k: ); Scanf ( % d , k); If (k % 2 = = 0) printf ( % d is even! \ n , k); If (k % 2! = 0) printf ( % d is odd! \ n , k); } For example 3: write the program, output a, b, the largest number i

文档评论(0)

1亿VIP精品文档

相关文档