Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Lab_1

.pdf
Скачиваний:
9
Добавлен:
23.02.2016
Размер:
1.11 Mб
Скачать

’ – ++ © . .

1.

: ++.Visual Studio .NET Borland Builder C++ -++

: Visual Studio .NET Borland C++ Builder.

1./0 1 /++. / ANSI/ISO C++.

2.7 189 : ; 1 /++.

3./ 18 0 Visual Studio .NET.

4./ Visual Studio .NET.

5./ 0 18 0, 1 @ .

6.B 0 1 ; 18 C .

7./ Borland C++ Builder.

8.

1. /0 1 /++. / ANSI/ISO C++.

F : ; 0 / ’: ,1 H , ; 18, 0 1 @0 . / 1 ; 1 01 , 1 ; 0 . I 1 : 1 :, 1 . B 00 /. 1989 @ K 8 0 L @ 18 0 M / (ANSI) 0 X3J11 1 1: 18 C

0 ; / (ANSI C).

 

 

R ; : S @ : / (ISO) 1990,

 

0 0 0 ; 0

 

ANSI/ISO

9899. U1 UNIX @ ; 0W 8 POSIX(Portable Operating System Interface – 18 H @ C ) – . B ; @ 1 /++,ANSI/ISO /++.

a : /++ 1 W : 1 8 , W ’ ; : . U1 : /++(/): 0 0 , : ( @ 0 ) 0, 1 @ :, 0 , ; , ; 1 ; 1 1 . U1 : /++ 1 , 1 : 8 0 , 1 . c 1 1 C 1 ;0 8 W 1 ; , ;9 0 1 . c 1 0: 8 1 ( ) @ C0 ’: . /8 189 0;: /++(/) 1 0 ’: , @ 0 Intel (IA32, IA-64), 0 @ Windows Xa, Windows 2000, Windows2003, Windows Vista, Windows 7 ; : 8 Visual Studio Visual Studio .NetH Microsoft, C++ Builder – Borland(CodeGear), Intel C++ Compiler – Intel, Open Watcom C/C++ – Watcom MinGW 1 G++ ( 1 C++ 1GNU -GNU Compiler Collection, GCC) 1 1 8 Unix Linux @ ). B ; W , Eclipse, 0: 8 1 /++.

1

’ – ++ © . .

2. 7 189 : ; 1 /++.

Microsoft Visual Studio. c 0; @ , 1: W 1 C++ 1 @ Windows 1 Hi : Microsoft. ci 1 iC 6.0 Microsoft 1 W 0 1:@ : : 1 : 1 : .NET. k @8 0 ; i ; 18 1 C 1 MFC WinForms. c @:W 18 1 H Windows.

Borland C++ Builder. @ CodeGear ( 1 C Embarcadero Technologies, 9 1 ; Borland Software Corporation, Inprise Corporation ) 1 C++. c @:W 1 H i Windows.

Eclipse. / H : IBM. / : 1 Java 1 0 i i 0 i : 1 i i 1 W 1 i , 0 0 1i C++. U1 i1 @iC 0W i9 i i1 , 1 GCC.

ci 0W 1 H : Linux, Windows, MacOS X, Solaris, AIX, QNX.

KDevelop. 5 i 1 KDE, 0W 8 UNIX Linux - 1 H i . 0W 1 GCC.

3. / 18 0 Visual Studio .NET.

P 1 @ 18 0( 1. Integrated Development Environment) Visual Studio .NET.

U1 18 0 0 :

;0W Visual Studio .NET;

0 : File – New – Project … ( 0 Ctrl+Shift+N);

0 1 0 , ’ 8 ( . 1.1), Win32 Project;

1 Name 0 0. U1 1 0, “FirstPrj” – 0 C, 0 0W Location, 0 1 : 0 („FirstPrj”);

1 , : Ok, W 8 1 1 9 0 0 ( .1);

1: 9 8 1 0 Application Settings, W Console application ( , 0 18 ) 1:W @8 Empty project ( 0 0 0 ) Precompiled header ( 0W0 );

W Finish – 9 9 0 .

2

’ – ++

© . .

a 1.

4. / Visual Studio .NET.

x ( 1. Integrated Development Environment,– IDE) Visual Studio .NET ( 1 VS .NET) 1 W : , 0 , 1: , ’ 0 1 ;0 , 1 , .

a 1 H0 @ C 0 - VS .NET:

3

’ – ++

© . .

4.1.y1 0 0 : File 1 : 8:

: ( : New) 9 (Open) , H 1 , 0 , ;

1 0 @ (Save selected items, Save selected items as... , Save All);

: 0 0 (Page setup...) 0 0 (Print...);

9 ( 0 91 0 H 10 „ 0 0”) H 1 , 0 @: ;

0 0 (Exit).

4.2.k : 0 : Edit 0 ; :

/ (Undo/Redo) 0 @ 0 @ C;

@: 0H 0 (Clipboard): , : , , 1 (Cut/Copy/Paste/Delete) 1 ;

90 , ; H 0 9 H (Find and Replace); H0 @ W: C H 0 9 0 0 0 0,0 W 8 0 0 H 1 (H 1 );

: H 0 0 (Advanced), @: 1 (Bookmarks), .

4.3.c0 : View 1 : 8 0(Solution Explorer, Class View, Resource View, etc.), ;(Show Tasks), 1: / 1: 1 0 1

4

’ – ++

© . .

0 (Toolbars), 1: ; ;(Full Screen), ; 0 9 @ C.

4.4. 1 0, 1 @ , 1 ; :W 8 : 0 Project, Build Debug. k , : : Project ; :

1 / 0 0 (Add Class…, Add Resource...);

/ 0: ’W 0 (Add New Item…, Add Existing Item…);

0 0 0 0 (New Folder);

c0 : Build 1 0 (Build…, Rebuild…, Clean…), C (Batch Build…), 1 C H 0 @ C (Configuration Manager…) 1 @ C C 0 (Compile).

L 1 ; 0 :W 8 : 0 : Debug. M 0 W ;1 :

1: / 1: 0 1 ; (Windows), 1 , ; / 0 8 (Immediate), 0 (Breakpoints), ; 0 (Call Stack), ;

0 0 0 ; (Start Without Debugging) 0 ; 1 ; (Start);

0 – 0 – 0 (Step Into, Step Over, Step Out);

0 9 @ C, ’ 1 ; 0.

4.5.c0 Tools 1 : 1 W 0 ; ( 1 ), 8 1 0 0 VS .NET (ActiveX Control Test Container, Error Lookup, Spy ++, . .), @: ( 0 Macros), 1:(Customize…, Options…), .

4.6.k : : Window 0 ; :

: 0 H 10 (New Window);

1 1 (Split);

0 (Cascade, Tile Horizontally, Tile Vertically) ;

9 1: ; (Windows…).

4.7.c0 Help 1 : 10; 8 1 1 0 (Contents…) : (Index…), 90 0 1: 1 (Search…), ; / 1: 1 C (Dynamic Help), ; H @ C 0 : (About Microsoft Visual C++…), ; C VS .NET (Show Start Page), 1 8 C (Check for Updates) C (Technical Support).

5./ 0 18 0, 1 @ .

P 1 @ 1 @ C 18 0 IDE VS .NET. L ; , 0 8 0, 1@ 0 1 ; :

5

’ – ++

© . .

// 6 7 8 9 7 ++.

#include "stdafx.h" #include<iostream> using namespace std;

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

{

const int MAX=100;

double A[MAX],B[MAX],C[MAX]; int nA,nB,nC,i,m;

do{

cout<<" Input number N <"<<MAX<<endl; cin>>nA;

}

while(nA<0 || nA>MAX); nB=nC=0;

for(i=0;i<nA;i++)

{

cout<<"A["<<i<<"]="; cin>>A[i];

}

do {

cout<<" Input index m ( 0<=m<="<<nA-1<<") "<<endl; cin>>m;

}

while(m<0 || m>=nA); for(i=0;i<nA;i++)

if(A[i]>A[m]) B[nB++]=A[i]; else C[nC++]=A[i];

cout<<" Rezult "<<endl; cout<<" B : "<<endl; for(i=0;i<nB;i++)

cout<<B[i]<<"\t"; cout<<"C "<<endl;

for(i=0;i<nC;i++) cout<<C[i]<<"\t";

cin>>i;

cout<< "Exit\n"; return 0;

}

/ :W 18 . B 0 0 00 (File – Save Ctrl+S).

S ; , 9 1 @ C. k ;0W 0 1 @ :(Debug – Start Without Debugging Ctrl+F5). ~ 1 010 0 18 0 , 0 0 0 Output/Error List 0 H @ 1 .

6.B 0 1 ; 18 C / 9 18 0, 1 @ .

x (IDE) Visual Studio .NET 32-

1 Visual C++ 1 Windows 1 H .NET.

• H Windows 1 0, IDE VS .NET 1 189 0; H , 1 : 8 0 H 1 , 0: 8 0 . M 1 /++ H Microsoft, @ 1 H H 0 Windows. M 1 ///++ 1 : 8, 8 @8 0 , , 0 0 ( 1: 0 ), 1 0.

M1: 0 0 0 W 18H 10 0. M 1 Microsoft Visual C ++ 0W H 1 0 9 .sln( .dsp prj )

6

’ – ++

© . .

L 1 ;0 0 : Debug( 1 ; ). 0 1 ;0 1 8 0 0 0 ; , 0 : .

c ; 0 1 ;0 1 0 8 1: 0: 0 H @ :, 0 1 1 . I ; : 1 1 0 / (Debug – 1 ; , @ C 0 : H @ W 1 ; , Relese – 1: C H @ C).

~ 8 1 , Build Rebuild W 8 1 8, : 8 1 . M ; 1 W 8 H 10. I ' – , 18 0 ; Windows-0 8 H 1 .

0 ' H 10 1 W , 1 1; . /1 , 1 error ( 1 ) warning ( ; ) 1 .

c 0 ; ; 0 , 1 1 8, W 1 . • ; 0 0 1 8 81 C C 1 .

c ; ;0 8 1///++.

‚ ; 8 ; 0 0 9 9 : 0. I ; 0:.

c 1 1 0 0 1 8 1 ; 8 0 0 0 1 0 .

0 ; 1 @ 0 9 9 : @8 ,9 9 : Windows 1 @ 0 9 H 10. L 1890 91 – 1 @ 0 1 : : 9 0 11 0 1 , 0 . c @8 0 1 C . L 1 90 <Enter> 1 0 1 1 0, ; 1 018 0. c0 8- 0 0 W .

R ;1 ; 1 ;0 Start Debug ( 1 ; ), Step Into ( 0), Step Over ( : 0). B ; 1 ; 0 0 Step Out ( ). c @0 1 W 9 , ; . c 1 ;; Step Into 1 0: , 0 0 0 C. / 1 9 0W 8 0 H0 @ W: 0 1 0 , 0 0 . ~ 18 W 8 1 ; , : :W 8 , 1 W 189 9 ;1 1 ; .

;1 1 ; W 0 (breakpoints), 1 : 8 0 , @ ,@8 @ ; : 8 18 1C W ; .

B 0 0 ; : Toggle Breakpoints – F9 : Debug .

A B 9 Debug:

M Step Into – , 0 H0 @ .

M Step Over – 1 W ; 0 0, 10 H0 @ .

7

’ – ++

© . .

M Continue – ;0W .

M Stop Debugging – W 1 ; , W; .

M Restart – W 1 ; , :; . I , 1 1 ; , @8 0 0 1 8 .

M QuickWatch…- W 1 0, 1 W W 1 : . F 9 8 ; 0 0 0 QuickWatch, C 0 0 @ : 1 9 <Shift>+<F9>. 9 1 0 8 . M Add ( ) 1 W 0 0 0 . M Recalculate ( 0 ) 1 W 0 CC 1 Expression ( ).

U1 1 0 8 ; 0 1 0 Variables. • 8 1 0 (0 1 ) @ ( 0 ). c 9 9 : 9 1 0 0 ; 8 @89 ' C, ; 1 0 CC. L C 9 @8 0 8 1 : :, 0 0 ; 1 0 – C (decimal) 9 @ C (hexadecimal).

M Continue(Start Debug) : Debug ( 1 ; ) – ;0W0 , 1 ; 0 0 .

M 0 Continue(Start Debug) ; : C 1 C1 0 Debug ( 1 ; ). B 0 ;0 8 0 1 1 ; Windows- 0 : 0 W 9 0 C H0 @ C , 0W 8 Continue(Start Debug) 1 0 ; 0 0. c1 ; ; @ WC H0 @ C 1 8 1 ;1 8 1 ; . k 0 9 0 Continue, 0 0 C 0 , 1 ; ; 1 ; , 00 ; 0 0 0 ; 0 H0 @ :.

c 1: ; 1 ; :, 0W 8 ;: @ C 1 9 <Alt>+<Tab>.

8. J K LM N L Borland C++ Builder.

1.k ; :W 8 : 1 0 1

C++Builder 5, ( : OPQ … ).

2.c 1 0 0 W 8 : • 1 – ++ Builder 6

Project1, ’W – Object Inspektor, H – Form1,0 – Unit1.cpp. K – Form1: .1.1.

3. U1 0 9 C N RKL S K N T L U P L ;( ) 0 V W. @ @ : 8 H 1 ( : 8 9 *.cpp, *.h, *.hpp), H 1 0 ( 9 *.res) ( W 8 0 0 H . 8 0 0: , 0 , ), H 1 0 ( W 9 *.bpr) ( H 1 H XML, 8 @ C 0, , H 1 1: 8 0 8), H 1 H ( 9 *.dfm) ( H 1,

8

’ – ++

© . .

8 H @ : H . M ; 0 H 10 H W H 1*.cpp). C++Builder W 0 18 : : 0 , @ W,1 H 0 LU N XX YQ K K Z V L.

[ T , M N T L W Z V L, S K :

3.1./ 0 [Local Drive]\Students\#Group\#Student\ #(Name)Job. L 1 : D:\Student\821\02\03. c 0 0 03, D – ’ 0.

3.2. k H 1 0:

File->Save

Project

As…

0

 

0 0

( 9 0

0

D:\Student\211\02\03),

H 10 Unit1 Project1 1 9 ( 1 0 ). L 0 J S L Y.

3.3.c W 8 0. U1 @8 0( “Play” : Run 1 9 F9),018 W H . U1 90, 0 : Run->Program Reset.

4./ “ 18 ” 0.

4.1.k 0 File->Close All.

4.2./ 8 : New : : File->New… .

4.3.• New Items 0 Console Wizard 0

OK.

4.4.• Console Wizard [/++] [Console Application], 9; 0 OK. c 1 @8 W 8 0 –

Unit1.cpp, 0 .

5.k W , 0 9 0 ; 18 , 9 0 : File->Save All.-

9

’ – ++

© . .

6.c W W 8 ( ) 0. 0W . 3.3. 0180, 8 H , W 1 , ’ 8 8.

7.• 0 W W CC 0 – 5-6.

8.U1 1 : 0 C++Builder, 1 0, W ; : 1 .

9.0W 0 3-7 !!! . U 1 0 0 – Unit1.cpp,

W :

#include <conio> #include <iostream> using namespace std; int main()

{

freopen("a.in", "r", stdin); int a, b;

cin>>a>>b;

cout<<b<<" "<<a<<endl; return 0;

}

10.U1 H 1 a.in , 0 New Items ( . 4.2.-4.3.)0 Text, ( File->Save As…)a.in, 9 9 Any file. U1 @8 , W 0 0 H 10 a.in 8 1 1 1 .

11.k W 0 ( ; 18 ).

12.k 0 W .

13.1 ; . R ; 0 0 @ , 8 0 0 0: Run -> Run to Cursor F4. c 0 0 H0 @ :: Step Over F8 0 H0 @ :: Trace Into F7. M 18 : Run->Inspect, Run->Evaluate/Modify Ctrl+F7, Run->Add Watch Ctrl+F5.

14.U1 C H @ C: 0 0 ’W ( 1 ’W H 0) 0 F1.

8 1 C Š1.

 

InFile

Q N K .

Q L *.in

i NP Y L

1

01a.in

/ 1 0 1 ; 0

5

10

 

125

 

 

@ 1 1.

 

 

 

 

2

01b.in

/ 1 0 1 ; n4 @ 1 1 .

2

 

 

16

3

01c.in

/ 1 0 1 0 0 0 (a+b)/a; ,b –

1

3

 

4

 

 

@ 1 1 .

 

 

 

 

4

01d.in

/ 1 0 1 ; 18

5

6

 

5

 

 

@ 1 1.

 

 

 

 

5

01e.in

/ 1 0, W @ @ 1 1 ,

-5 -6

-6 -5

 

 

’W .

 

 

 

 

6

01f.in

/ 1 0, 0W 0 0 @ 1 1,

-5 -5

-10

 

 

’W 0 0 1 ; 0

 

 

 

 

 

 

0.

 

 

 

 

7

01g.in

/ 1 0, 0W @: @ 1 1,

3

2

 

1

 

 

0 0 1 ; 0

 

 

 

 

 

 

0.

 

 

 

 

8

01h.in

/ 1 0 1 ; 18

3

4

 

4

 

 

@ 1 1.

 

 

 

 

9

01i.in

/ 1 0, 8 H 0

1999

 

99

 

 

0 .

 

 

 

 

10

01j.in

/ 1 0 1 ; 0

0

0

2 2

8

 

 

; .

 

 

 

 

10

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]