1 , . , . 2 - , , . 3 , . , .
for (.3):
1. 1.
2. 2.
3. 2 (), ( , ), 3 2, 2 (), , for.
for ( 1; 2; 3) ; while :
1;
while ( 2)
{ ;
3;
}
, . , , for while. for :
int x, Sum;
cin >> x; //
for (Sum = 0; x!=0;)
(
Sum += x; //
cin >> x; //
}
cout << Sum; //
for , . .
int i,b;
for (i=1; i<10; i++)
cout<<i<<^2=<<i*i<<endl;;
1 9. i , 1 for, ( 1) 3, 2. ,
for (c_=_;
_<_+1; _+=_)
++ . , ( ) for : , , , 1 -1.
for , .
:
int main()
{ int top, bot;
char string[100], temp;
for (top=0, bot=100; top < bot; top++, bot--)
{ temp=string[top];
string[bot]=temp;
}
return 0;
}
, , top bot. , 1 3 , , .
|
|
for 3 . .
unsigned int n, f;
cin >> n;
for (unsigned int i=2, f=1; i<=n; f*=i++);
cout << f;
, ( , ) for.
for.
for (i=0; t[i]<=10; i++);
i t, 10.
for . , break. :
for (;;)
{...
if ( ) break;
...
}
break . break switch, do while, for, while. break , .
continue , break , , 3 for .
, 20 .
int p, val, i;
for (i=1; i<=20; i++) // 20
{
cin >> val; //
if (val==1) continue; //
if (val==0) // 0
{pr=0;break;} // ,
pr*=val; //
}
cout << pr; //
, . , .
1. ++ .
2. .
3. , .
4. , .
5. .
6. .
7. .
:
- ;
- ;
- ;
|
|
- ;
- .
:
11 ()
1. n . , n . .
#include <conio.h>
#include <math.h>
#include <iostream.h>
main()
{ int x=0,c=0,n=4,first,otric=0,bol=0,i;
clrscr();
cout<<"Vvedite 1-oe chislo: ";
cin>>first;
if (first<0) otric++;
for (i=2;i<=n;i++)
{
cout<<"Vvedite "<<i<<"-oe chislo: ";
cin>>x;
if (x<0) otric++;
if (x>first) bol++;
}
cout<<"Kol-vo otricatelbnbIx chisel:"<<otric<<"\n";
cout<<"Kol-vo chisel bolbshix pervogo: "<<bol;
getch();}
. , 3.
#include <conio.h>
#include <math.h>
#include <iostream.h>
main()
{
int x,c,n,i,m=0;
clrscr();
do
{
cout<<"Vvedite chislo: ";
cin>>x;
c=x%100;
n=c/10;
i=c%10;
if (x/10!=0)
if ((n%3==0)&&(i%3==0)) m++;
}
while(x!=0);
cout<<"Iskomye chisla: "<<m;
getch();
}
1
1. n . , .
2. . , .
2
1. , . , .
2. . , 3. , .
3
1. n . , n . .
2. . .
4
1. 1. , . , .
2. . .
5
1. . , . , .
2. . , 5.
6
1. 0. , 20, 100 3.
2. . , 3.
7
1. n , n- . , [ x, y ].
2. . , .
8
- . , .
- . , 3.
9
1. . , .
2. . .
10
1. 100 . .
2. . . .
|
|
1. . ., . . ++. .: -, 2007 ., - 288.
2. .. . . . .:BHV, 2008 . 439.
3. . ., . . . : . , 2006 . 208.
4. . ++. . .: , 2008 ., 1104.
5. .. .. : . .: , 2007 . 600.
6. . C++. .: , 2007 ., - 800.