.


:




:

































 

 

 

 


bool -> char -> short-int-unsigned int-long-unsigned long-float-double-long double




, , . unsigned int int 2 . , : bool, short, char. int.

( ).

. . , .

int I=27;

short S=2;

float F = 22.3;

bool B = false;

I-F+S*B

? ³ , . int-float+short*bool. , short bool int.

int-float+int*int. float = 0. int, . int-float float. :

 

- , .

 

float.

float rez = I-F+S*B; // 27-22.3+*0

cout << rez << endl; // = 4,7

, .

񳺿 .

 

, .

 

int i=3;

int j=2;

cout << i / j; // = 1. int

, float. :

int i=3;

int j=2;

cout << (float) i / j; // 1.5

 

. . /. , .

 

, .

 

++. 5. . '. .

 

Joker
, 10 2014 00:19 : 2680
- , '. , . : 1. г i/ 2. . 3. . 4. ' . г /. , 1, . , . 5++; . a++; , a = 5;. , (--a; a--;), ? . : --a; ++a; : a--; a++; 1: int a = 8; cout << a; // 8 a++; cout << a; // 9 ++a; cout << a; // 10   . . int a = 8; cout << ++a; // 9 cout << a++; // 9 cout << a; // 10   , ( ) / 1.   cout << a++; .  
==
!= ˳

 

< ˳
> ˳
<= ˳
>= ˳

 

. , A 5 10, 2 . >=5 A<=10. , .

!=
&&
||

A>=5 && A<=10.

 

(&&)

ᒺ 2 , true () false (). true, false

_1 _2 _1 && _2
true false false
true true true
false true false
false false false

true , true.

true - , (true). False 0, -1 䒺 - true.

5-10

#include <iostream>

#include <conio.h>

using namespace std;

int main()

{

setlocale(LC_CTYPE, "ukr");

double a;

cout << "i --> ";

cin >> a;

 

cout << ((a >= 5) && (a <= 10)) << endl;

 

cout << " 0 - i." << endl;

cout << " 1 - i." << endl;

 

_getch();

return 0;

}

 

(||)

ᒺ 2 (true) , . false, false. , true, ( ) .

_1 _2 _1 || _2
true true true
true false true
false true true
false false false

 

a 5 10. .

view source

print?

#include <iostream>

#include <conio.h>

using namespace std;

int main()

{

setlocale(LC_CTYPE, "ukr");

float a;

cin >> a;

cout << ((a <= 5) || (a >= 10)) << endl;

cout << " 0 - i 5 10"<< endl;

cout << " 1 - i 5 10" << endl;

 

_getch();

return 0;

}

 

(!)

, ᒺ ( ). ³ .

_ !_
true false
false true

true false false true.

 

 

++. 6. if switch.

 

Joker
, 21 2014 23:09 : 2737
: 1. if 2. switch 3. . if . if . . if (__) { _1; } else { _2; } __ . _1 , __ true. _2 , __ false. _1, _2 . _2, _1. . #include <iostream> #include <conio.h> using namespace std;   int main () { int n,x;   cin >> n >> x;   if (n>x) { cout << "n > x" << endl; } else { cout << "x>n" << endl; }     _getch(); retrun 0; } : 5 10 (5<x<10)? 2 : 1) X>5 2) X<10 , , ᒺ. : If (X>5 && X<10)   r : , 쳺 : if (a-b) . , -b. true false. , false = 0 true!=0 , a-b = 0, else. a-b 0, if.   : , () , : if(a == b) () if(a = b) , if else, . else . : if () { _1 } // : if () { _1 } Else { } //   if-else . , . , 500 ., 5%. 1000 , - 10 %. , . . if-else. : if (_1) { _1 } else if (_2) { _2 } else { _3 } (else if ()). 5-8 - , . , - . , - 4 5, 8 9. _1, _2, _3, , . ( ). . #include <iostream> using namespace std;   int main () { setlocale (LC_CTYPE, "ukr");   double price, discount;   cout << " --> "; cin >> price;   cout << "\n" << " = "; if (price >= 500 && price < 1000) { discount = 5; cout << discount << "%" << endl; } else if (price >= 1000) { discount = 10; cout << discount << "%" << endl; } else { discount = 0; cout << discount << "%" << endl; }   cout << " = " << price - (price * (discount / 100)) << endl;   return 0; }   switch , if-else. - . if switch. , if. 3 . if, switch . . : switch () { case _1: ij_1; break; case _2: ij_2; break; default: _; } , default: break;. . . . . _1 . _1 = 1. _1 1. , ( ) 1. , _1. , case. , default. ( ) switch(a) { case '!': cout << "1" <<endl; break; case '@': cout << "@" << endl; break; default: cout << "^^^^" << endl; }     if, . : ? ij_1: ij_2; . . : view source print? #include <iostream> using namespace std; int main () { int b; cin >> b; ( (b!=0)? cout << "Yes": cout << "No"; b 0, Yes, b = 0 No.    

 





:


: 2017-02-25; !; : 290 |


:

:

, .
==> ...

1674 - | 1487 -


© 2015-2024 lektsii.org - -

: 0.025 .