Высокоуровневые методы информатики и программирования Лекция 4 Выражения и операторы

  • Published on
    04-Feb-2016

  • View
    70

  • Download
    0

Embed Size (px)

DESCRIPTION

4 . . . 3. . . - PowerPoint PPT Presentation

Transcript

Expressions and statements

4

1 ( )

3. , , ( ), , , . :(a+1)/2.55 // a == 5 // . .

( ). byte, decimal. , :int a = 5; float f;f = a/4; // f = 1.0, /4 int = 1f = a/4f; // = 1.25, float = 1,25 . . . :double aaa = 2 / 4 * 0.5; // double = 0.0double bbb = 0.5 * 2 / 4; // double = 0.25 . , . , :int a = 5; float f;f = a/4; // f = 1.0, /4 int = 1f = a/4f;// f = 1.25 :double aaa = 2 / 4 * 0.5; // 0.0; 2/4 int 0double bbb = 0.5 * 2 / 4; // 0.25

3. , . , , , . ;. . C# . : x = expr; , , :x1 = x2 = ... = xk = expr; expr . , : ()

.:int x=5;int z;z = x; // (5) ( ).:Box p1;p1 = new Box (4,5); // Box p2;p2 = p1; // if switch. if - , switch .

if if:if(_1) _1else if(_2) _2...else if(_K) _Kelse _N if . , true false. , . else if, , . else-. if then-. if . true, ( ), , true. if.

switch, , . C# switch:switch(){ case __1: [_1 __1] ... case __K: [_K __K] [default: _N __N]} switch . switch-. case . , case-. ( break), switch. switch- , default, , switch . default . , , , .case- . case , switch-. switchpublic void Starosta(string group){ string stud; switch (group) { case "8551": stud = " .."; break; case "8552": stud = " .."; break; case "8553": stud = " .."; break; default : status = " "; break; } Console.WriteLine (" {0} {1}", group, stud);}

, if . : int period =0; if ((age > 0)&& (age = 7)&& (age = 17)&& (age

Recommended

View more >