.


:




:

































 

 

 

 


. ,




 

:

(, ASCII, ), ;

(, , ). , _. . , abc Abc , .. ;

() , , : +, -, /, *,!, &, |; : !=, =, >= ; ; ; : (), [ ] {};

, - . : int, char, if, while, new;

. (, , );

, . . , -, , ;

, , . ++:

//

/*... */ , .

 

 

.

, . , , .

.

 

:

;

, ;

, .

 

1.1 ++ .

 

1.1. ++

char -128 +127
unsigned char 0 255
short -32768 +32767
unsigned short 0 65535
int 2147483648 + 2147483647
unsigned int ( unsigned) 0 4294967295
long 2147483648 + 2147483647
unsigned long 0 4294967295
float 3.4e-38 3.4e+38 (7 )
double 1.7e-308 1.7e+308 (15 )
long double 1.2e-4932 1.2e+4932
bool true () false ()
void . , , ,

( char unsigned char) ASCII 0 127. -8 CP-1251. 128 255.

, , . wchar_t.

++ . static _ cast.

:

float f = 5.25;

int i = static_cast<int>(f); //i=5

int first = 5, second = 10;

double result=static_cast<double>(first)/second;//result=0.5

// !

double result=first/second; //result=0!

, .

++ , :

const int X = 240; // X, , 240

const int Z = 0xF0; // Z, ,

// F0

const !

:

enum { Red, Yellow, Green }; // Red, Yellow, Green

// 0, 1, 2

enum { EMPTY =-1, FULL =100}; // EMPTY -1, FULL 100

, . c , .

++ , , . , , ( ), :

int a, b = 10; // a, , ;

// b, , 10

float f = -2.5; // f, , -2.5

char c = A ; // c, , 65 ( A ASCII)

bool b = true; // b, , (1).

.

, . .

( , ), , , .

, , .

, . . , . :

auto . . . , , . , ;

extern . . , , ;

static . . ;

register . auto, .

, . :

namespace _{}

Namespace _;

 

:

namespace demo {

int i = 1;

int k = 0;

}

namespace std; // - std

:: using.

 

 

. , . . , . , , , , , .

. . 1.2 , ++, ( , ). , , ( ), ( ) ( ).

 

 

1.2 C ++

 

++ 1
-- 1
sizeof
~
!
- ( )
+
&
*
new
delete
(type)  

* / %
+ -
<< >>
< <= > >=
== !=
& ()
^
| ()
&&
||
= *= / = %= += -= << = >> = & = | = ^= ,

?:

 

. , , , .

1 (++ --) . , , , ++ i, i ++. , , , .

sizeof .

 

. ( -) . (!) 0, ( ), 1. . , . (~) .

(<< >>) . , . (<<) . (>>) , , .

(<, <=, >, >=, ==!=) . .

(&& ||) .

(&, |, ^) . .

(=, +=, -=, *=, /= ..) . , , a += b; a = a + b;

(?:) . :

? _1: _2

true ( 0), _1, _2. ?: if.

:

i = (i < n)? i + 1: 0;

grade >= 60? cout<<" \n": cout<<" \n";

 

++ -. - , , . : , , ++.

 

- :

int scanf(const char* format, ); //

int printf(const char* format, ); //

stdio. h. format. , ( ) ( ) , , %, .

 

 

:

#include <stdio.h>

Int i;

printf (" \ n "); // " "

// (\n)

scanf ("% d ", & i); // i

printf (" % d \ n ", i); // i

//

 

 

C ++ - iostream. - cin cout , << >> . cin, cout std::, using.

 

C ++ - :

#include <iostream>

Int i;

std::cout << " \n";

std:: cin >> i;

std:: cout << " " << i << std:: endl; // endl

 

#include <iostream>

using std::cout;

using std::cin;

using std::endl;

Int i;

cout << " \ n ";

cin >> i;

cout << " " << i << endl;

 

# include < iostream >

using namespace std; // std,

// C ++ //

Int i;

cout << " \ n ";

cin >> i;

cout << " " << i << endl;

 

- , C C ++ .

 

 

 

?

:

();

( );

().

, , , .

 

:

.

, __ _.

, . C ++, ( 1.3).

1.3

C ++
    A; B; A, B. A, B sum = int1 + int2; cout << " " << sum << endl;  
__   if (P) A; else B; P ( ), A, B. If(x>0) y++; else y--; int num, div; if (!(num%div)) cout<< " "<<endl; else cout << " "<< endl;
_   if (P) A; P ( ), A. if (x>0) y ++;  
  switch (K) { case 1: A; break; case 2: B; break; case 3: C; break; default: D; break; }; K - , : K = 1, A; K = 2, B; K = 3, C D; char op; bool f=true; int a, b, res; cin >>a>>b>>op; switch (op) { case '+': res=a+b; break; case '-': res=a-b; break; default: cout<< "\n " << endl; f=false; break; } If (f) cout<<res<< endl; break !
_ ( )   while (P) A; P( ), A . while (N>0) N- -;  
__ ( ) for (; ; ) A; , . . . for (int i = 1, s = 0; i <=100; ++i) s += i; // //: // i =1, s =0+1=1 //i=2, s=1+2 //i=3, s=1+2+3 // //i=100, s=1+2++100 //i=101
_ ( )   do A; while P;   A , Po( ). do N--; while N>0;  

 

:

do while , ;

for , , ;

while , , .

 

. ++ ( !):

continue . ,

break . , .

return (). .

 

( 1.3 A, B). . , .

, { }.

:

if (x >0) {

y = 1; k ++; // y =1 k ++

} // x > 0

, , .

_ :

, , . : , , .

 

 

 

C ++ cpp.

(*. cpp) :

, # include ;

(), , , ;

, main .

 

 





:


: 2018-10-14; !; : 328 |


:

:

.
==> ...

1707 - | 1653 -


© 2015-2024 lektsii.org - -

: 0.1 .