.


:




:

































 

 

 

 


. -.

3, 4, 5

3.1.

3.2.

3.3.

 

:

- for, while do-while ;

- ;

- ( ) ;

- for, while do-while ;

- setw (. ).

1.

do while, ? (y/n) . , . , (, ).

2.

, setprecision(n) .

3.

, .

, (: 0.001, 0.0001,, 0.000001).

 

, pi, e, math.h. ++, . #include <math.h> #define _USE_MATH_DEFINES. math.h.

 

(3.1)

 

#include "stdafx.h"

#include <iostream>

#include <conio.h>

#include <cmath>

#include <Windows.h>

#include <stdlib.h>

#include <time.h>

#include <clocale>

using namespace std;

#include <iomanip>

#define N 20

 

int main()

{int mas[N]={0};

char ch;

do

{int a,b;

setlocale(LC_CTYPE, "rus"); //

srand(time(NULL));

cout<<" :";

cin>>a>>b;

for (int i=0; i<N; i++)

{mas[i]=a+rand()%(b-a+1);

cout<<"mas["<<setw(2)<<i<<"]="<<mas[i]<<endl; //

}

cout<<" :"<<endl;

for (int i=0; i<N; i++)

cout<<setw(8)<<mas[i];

cout<<endl;

_getch();

cin>>ch;

} while ((ch=='Y')||(ch=='y'));

return 0;

}

 

1. - 3.1.

2. a b.

3. .

4. .

 

. -.

ios, . .

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

, hex cout . :

cout << "\n : "<< 15 << hex;

cout << "\n : "<< 15;

:

: 15

: 0xF

, hex cout. 15 .

( ) , . . . , . , hex, oct, dec:

 

cout << 15 << hex << 15 << oct << 15 << dec<< 15;

:

150xF01715

- ++ : .

:

dec - ;

hex - ;

oct - ;

ws - (, '\t ' \v, '\n', '\r', \f);

endl - , ( ) ;

ends - ;

flush - , .. ( ).

left - ( );

right - ( );

fixed - ( float, double) , .

, , , ws ; endl, ends, flush - .

dec, hex, oct, , , .

endl , . , :

cout << "! ." << endl;

endl , cout .

iomanip:

setbase(int n);

(n) . n : 8, 10 16.

resetiosflags(long L)

() L ( );

setiosflags(long L)

( ) - ( );

setfill(int n)

n -, .

setprecision(int n)

n , .. .

setw(int n)

n .

. , setw(int n) , .

 



<== | ==>
| 2. .
:


: 2017-01-28; !; : 656 |


:

:

, , .
==> ...

1897 - | 1538 -


© 2015-2024 lektsii.org - -

: 0.014 .