.


:




:

































 

 

 

 


2.




Visual ++ 2010 Windwos. : , (native); , (Common Language Runtime- CLR) Net Framework. .

Visual C++ , ( ). , . , ++ Visual C++, .

. Visual ++. , --(Shift+Ctrl+N).

1.1

 

Win32.

1.2

, OK. .

1.3

Lr1.cpp. Lr1.cpp , . - -/++-, .

. :

#include "stdafx.h"

#include <iostream>

 

 

int _tmain(int argc, _TCHAR* argv[])

{

std::cout<<"Hello World!!\n";

return 0;

}

. include stdafx.h , . #include <iostream> -. _tmain. , main. _tmain, Unicode.

std::cout .

F7. :

1>------ : : Lr1, : Debug Win32 ------

1> 02.09.2012 16:27:43.

1>InitializeBuildStatus:

1> "Debug\Lr1.unsuccessfulbuild", "AlwaysCreate".

1>ClCompile:

1> .

1> Lr1.cpp

1>ManifestResourceCompile:

1> .

1>Manifest:

1> .

1>LinkEmbedManifest:

1> .

1> Lr1.vcxproj -> D:\ASP\\ \C++\Lr1\Debug\Lr1.exe

1>FinalizeBuildStatus:

1> "Debug\Lr1.unsuccessfulbuild" .

1> "Debug\Lr1.lastbuildstate".

1>

1> .

1>

1> : 00:00:01.61

========== : : 1, : 0, : 0, : 0 ==========

, error. . , cout cout1:

1>d:\asp\\ \c++\lr1\lr1\lr1.cpp(10): error C2039: cout1: "std"

1>d:\asp\\ \c++\lr1\lr1\lr1.cpp(10): error C2065: cout1:

1>

1> .

1>

1> : 00:00:00.69

========== : : 0, : 1, : 0, : 0 ==========

debug.

Ctrl+F5.

1.4

. . . , 3 float: a,b, S. cin. :

#include "stdafx.h"

#include <iostream>

 

int _tmain(int argc, _TCHAR* argv[])

{

setlocale(LC_ALL,"Rus"); //

float a,b,S;

std::cout<<" !!!\n";

std::cout<<" :";

std::cin>>a;

std::cout<<" :";

std::cin>>b;

S=a*b;

std::cout<<" :"<<S<<"\n";

return 0;

}

, C++ , .. s S .

 

1. , = -2,73+0,23x2-1,4. x y.

2. ( 405,9 ).

3. ( 1066,8 ).

4. : s =a*h/2, ; h .

5. : s = (a+b)*h/2, b ; h .

 

1. Visual C++. ;

2. , , 1.2;

3. , ;

4. .

1. Visual C++ 2010?

2. ?

3. ?

4. iostream?

5. ?

2.

: if

 

2.1.1 if

if (, ) , , .

:

if ()

;

. false, . true, . :

if (bigNumber<smallNumber)

bigNumber=smallNumber;

 

bigNumber smallNumber. bigNumber smallNumber, smallNumber.

, :

if (bigNumber<smallNumber)

{

Tmp=bigNumber;

bigNumber=smallNumber;

smallNumber=tmp;

}

, , .

int main(int argc, char* argv[])

{

int bigNumber, smallNumber;

cout<<"Enter a big number:";

cin>>bigNumber;

cout<<"Enter a small number:";

cin>>smallNumber;

 

if (bigNumber>smallNumber)

cout<<"Thanks\n";

else

cout<<"Oops. The second is bigger\n";

return 0;

}

if .

 

2.1.2 switch

 

switch () . 2.1. :

switch (){

case __1: [__1]

case __2: [__2]

case __: [__]

[default: ]

2.1 switch

( ), , , .

, , .

break. , . . , , default ( switch ).

:

switch (choice)

{

case 0:

cout<<Zero;

break;

case 1:

cout<<One;

break;

case 2:

cout<<Two;

break;

default:

cout<<default!;

break;

}

 

if

1. , . , ( ), . (, , ).

.

,

<Enter>.

12 0

. .

2. . . (, , ).

.

:

() -> 3.5

() -> 7

! .

3. , . . (, , ).

.

:

() -> 15

()-> 27.3

(1 , 2 ) -> 2

: 9.68

4. , . , , . .

(.) -> 2.90

! 60

<Enter>

5. . 10% , 1000 . .

<Enter>

-> 1200

10%

: 1080.00 .

6. , , . (, , ).

<Enter>

-> 23

23 .

 

2.2.1 switch

 

1. , , , .

2. , ( , ). . (, , ).

 

.

:

-> 423

( )-> 3

:

: 2.20 .

: .60 .

 





:


: 2016-12-17; !; : 540 |


:

:

, , 1:10
==> ...

1661 - | 1588 -


© 2015-2024 lektsii.org - -

: 0.042 .