.


:




:

































 

 

 

 


, , , , , .




, . - <stdio.h>. stdout.

 

" " :

  • (),
  • (\n , \t , \a , ),
  • , %.

" " : % (1 ), (, , , ) (2 ) (3- ).

7. printf()

   
% + ; ; - ; # (0 8-, 0 0 16-); ( ): min min ( ); 0 min , ; ( ): .0 d, i, o, u, x ; e, E, f ; . precision , , float double; h d, i, o, u, x short; l d, i, o, u, x long, e, f, g double   ; c d, i 10- (signed int) o 8- (unsigned int) u 10- (unsigned int) x 16- (unsigned int) f mmmm.nnnnnn (float) e, m.nnnnnnExx (float) g, G e f ( ) s p ()  

 

, . , . : , , , , ( ( ) ).

precision, , , :

(, %Ns) precision N N ;

(, %Nf %Ne) precision N N, ;

(, %Nd %Ni) precision N N ; , precision, () ;

(, %Ng %NG) precision N , .

 

- , , , . .

h l (, %lf, %hu) :

h d, i, o, x , short int, u short unsigned int;

l d, i, o, x , longt int, u long unsigned int, e, E, f, g, G double, float.

 

:

% %;
d, i ;
e, E float double, [-]m.nnnnnn[+-]xx, n ; 6;
f , float double, [-]mmm.nnnn, n ; 6;
g, G %e %f, ;
( );
( , );
s : , , ;
u ;
, ( 0).
   

 

C++ -. , () -. - ( ) , .. - -.

:

¨ ;

¨ ( );

¨ ( ).

-----------------------------------------------------------------------------------------

int gets(char * str). stdin str, , \n . \n , \0. NULL.

char str[20];

gets(str); //qwer qwert qwerty

puts(str); //qwer qwert qwerty

 

gets() , , str, .

stdin ("" ) scanf(), . , , . . EOF ( 1).

scanf(), gets(), , .

:

int scanf(" ", 1, 2, .);

scanf(). , . , , .

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

, % (. 2).

 

8. scanf()

% l long d, o, x, u double f, e h short d, o, x, u d 10- o 8- x 16- c s l float double f float double u p ()

 

, , , (, , .). , , . scanf() , ( ), .. .

 

:

1. scanf() (, \t, \n, \v);

2. scanf() , ; , ;

3. &; & .

4. ( ), , .

:

short sh; int ii; unsigned uu; long ll;

scanf("%hd %d %u %li", & sh, & ii, & uu, & ll); // : 1 2 3 4<enter>

// : 1<enter>2<enter>3<enter>4<enter>

, .
, , .., . , scanf("%d%d", &r, &); 10 20 , 10,20 .

 

scanf("%hd,%d,%u,%li", & sh, & ii, & uu, & ll); // : 1,2,3,4<enter>

(,) scanf() . , "%d,%d" scanf() , . , scanf() .

, , , . , addr, scanf("%s", addr); ( addr &).

 

!!! scanf() , , ( ).

 

:

¨ ;

¨ ;

¨ ( );

¨ ( ).

 

. , c , .

-----------------------------------------------------------------------------------------

/ ++

- <stdio.h>, ++ - -, <iostream>. - . - ++ , , - ++ .

- ++ :

(.. , - ), , , .

, , ( ). , .

 

- :

o >> ( ) ; ; , ;

o << ( ) (int, float, char, ..) ; , .

<iostream> ( ):

cin istream, , ;

cout ostream, , .

- , .

 

; , , , .

:

o ( ) ;

o <enter>; <enter>;

o ;

o , ;

o ; ;

o (, int ii; double dd; cin >> ii; cin >> dd; 123. 456, ii 123, dd 0. 456);

o : +, -, ; (, , , <enter>);

o 16- a, A, b, B, .f, F;

o e E ;

o 1 (true) 0 (false);

o ; -;

o ( ) <enter>; , qwe ( <enter>); noskipws (cin >> noskipws >> c1 >> c2 >> c3;); : ch = cin. get (); cin. get (ch); cin. read (& ch,1); ( , ); ,

o , (\r\n), <enter>; ; \0;

o cin. get (), cin. getline (); cin. ignore() , ( , 1, -, , );

:

o ; 0xFFFF 65535;

o 6 (, 7.123456789 7 .123457, 123456789.15 123456789.150000 1.234568+008;

o , ; : , , , void* (char* s = aaaaa\n; cout << s << << static_cast<void*>(s) << \n;);

o bool (1 true, 0 false);

o ;

o ; , (char n = -100; cout << int(n) << \n; put () (char ch = a; cout.put(ch);) write() (char ch =a; cout.write(&ch, 1);

o \0; << string (string s3 = aaaaa\n; cout << s3;); ( string) write() (char *s1=bbbbb; cout. write(s1, strlen(s1));

o ; << (, cout << d = f << \n; (cout << d) = (f << \n); ; : cout << (d = f) << \n;)

-----------------------------------------------------------------------------------------





:


: 2018-10-15; !; : 260 |


:

:

80% - .
==> ...

1702 - | 1557 -


© 2015-2024 lektsii.org - -

: 0.049 .