do-while , , while, - , . do-while , - true.
do-while, while, . do-while : . ().
do-while : do..while (true).
-----------------------------------------------------------------------------------------
( ) for
for :
for (; -; ) ;
. , :
for (int i=0, j=2; ..)
int k, m;
for (k=1, m=0; ..)
, , .
- : , bool, true, .
. .
for ( ). for , while for, , :
for (b1; b2; b3) à b1;
while (b2) {
;
b3;
}
for
for :
, , , , :
for (unsigned i = 0; i < 100; i += 5) cout <<i<< endl;
for (unsigned s1 = 127; s1 <= 255; s1++)
cout << s1 << " " << char(s1) << endl;
for (double delta = 0.1, x = 1.; x <(30.+delta/2); x += delta)
cout << x<< endl;
for (char s ='0'; s <= '9'; ++s) cout << s << " " << int(s) << endl;
for (char s ='A'; s <= 'Z'; ++s) cout << s << " " << int(s) << endl;
for (char s ='a'; s <= 'z'; ++s) cout << s << " " << int(s) << endl;
enum den {pon, vt, sr, chet, pjat, sub, voskr};
|
|
for (den d = vt; d <= sub; d = den(int(d)+1))
cout << int(d) <<endl;
for (bool b = false; b < true; ++b)
cout << b <<endl;
!!!
for (bool b = false; b <= true; ++b)
cout << b <<endl;
, ???
:
unsigned n; for(ci >> n; n; --n) cout <<n << endl; // n=5: 5 4 3 2 1
unsigned n; for(cin >> n; --n;) cout <<n << endl; // n=5: 4 3 2 1
unsigned n; for(cin >> n; n--;) cout <<n << endl; // n=5: 4 3 2 1 0
, :
for (unsigned i = 0, j = 2; ..)
unsigned k, m; for (k = 1, m = 0; )
, 1 ( , , ..):
for (unsigned i = 0; i < 100; i += 5)
:
for (double k = 100; k < 185; k *= 1.1) cout << k << endl;
:
for(unsigned k = 1, z = 0; z <= 96; z = 5 * k + 23, k = k + 2)
cout << z <<endl;
//0 28 38 48 58 68 78 88
, ;
;
unsigned n; cin >> n; for (; n; --n) cout << n << endl;
unsigned n; cin >> n; for (; --n;) cout << n << endl; // !!!
unsigned n; cin >> n; for (; n--;) cout << n << endl; // !!!
:
unsigned n,m; for (cout << "input m:", cin >> m; m < 10; ++m)
{n = m; cout <<n << " " << m << endl;}
, :
for (double delta = 0.1, x = 1.; x < 30.; x += delta)
{delta += 0.5;
cout <<setw(5)<< x << " " << setw(5) << delta << endl;
}
:
1 0.6
1.6 1.1
2.7 1.6
4.3 2.1
6.4 2.6
9 3.1
12.1 3.6
15.7 4.1
19.8 4.6
24.4 5.1
29.5 5.6
:
for (double i = 0.0; i < 200000000; i++);
//
for (unsigned int t_beg = time(NULL); time(NULL)- t_beg!= 10;);// #include <time.h> time(NULL)
//
const int DELAY =100000000;
int main ()
{ long i; int n;
cout << "sec=?\n";
for (cin >> n; n; n--) //
for (i = 0; i < DELAY; i++);
_getch();
return 0;
}
for ( ):
float x =1;
cout << "Enter value of x: "; cin >> x;
for ( float d = 1, r = 1e-5f, y = 0; d > r; y=cos(x), d=abs(y-x), x=y );
cout << x << endl;
:
|
|
for (;;);
-----------------------------------------------------------------------------------------