Вы находитесь на странице: 1из 10

1 (2)

.
Microsoft Visual C++ 2005
(). .
++

( :
(1) Gilberg R.F., Forouzan B. Data Structures: A Pseudocode Approach with C, 2nd ed., Course Technology
(Thomson Learning), 2005
(2) Forouzan B., Mosharraf F. Foundations of Computer Science, 2nd ed., Thomson Learning, 2008
(3) .. . /C++. . -, 2006
(4) .., .. : , 5- ., .--, 2008
(5) .. - ++, 2- ., .
, 2001
(6) ., . Visual C++ , -, 2008
(7) . ++. , . ., 5- ., , 2007
(8) .., . , . ., , 2001
(9) Heathfield R., Kirby L., et al. C Unleashed, SAMS Publ., 2000)

,
,
,
.
, , ;

.
,
.
,
. ,
,
. - ?
, ,
, ,

. , , UML (.
, Pseudocode, ., CS 341).

UML (Unified Modeling Language / )

, , ,
(),
(, -
UML,
-). , UML
(. ). ()

.
(computer and programming researchers and scientists) 3
(. . 3 )
1

(), .. ,
, :
- (sequence) / 1 /
- (decision) / 2 /
- (repetition) / 3 /.

, ,
(). ()
UML :

/ 1 /

/ 2 /

/ 3 /

,
(, , ). , ,
, (

).
, ()
, Pascal C (, -
/ / ).
, ,
, , :
(1)
, ,
(
).
(2) , /
,
, ,
: ;
, ,
.
: ()

,
. ,
; ()
,
2

(-) (-) , :
() .
, null
.
(, , )
:
:
,
:
- ,
:
(true), ; (false),

(3) (statements)
, (assign), (input),
(output), (add), (loop). (nested
statements), .. , ,
(
/). , ..
/, { }.
(--),
1,

(). , /C++
for, while do-while .
1
{

termPro
resTemp
resTemp tempPro totalExam

2
{

termPro <-
resTemp <-
totalExam <- termPro + resTemp

( 1 2)

(.
);
(stepwise refinement) (.
Program Development by Stepwise Development, Comm. ACM, 14, 4, (Apr 1971), pp. 221-227).
. , ,
: ( . )
ITiSCE (2002 .).
- 21 , .

, (assign)
(add) ; ,
,
. ,

.
, ,
() .
,
; ()
.
, :
(1) (.. a, x, y, z ..),
(2) () ,
sum, denom, total ..
(sumOfNumbers, gradesTotal ..)
() ;
,
sum total,
(3) - ,
sum of numbers sumNum, total of
grades gradTotal.
,
, ..
++ (), ;
,
_ (underscore symbol).

(, int, for, double, break ).
, , ,
31.

. , i, j k (, l
() ,
1 (); )
, s t ,
, ,
. .
, , , arrsize, arrSize arr_size,
, . ,
, ,
. (),
, .
(namespaces) ++
.
,
:
, ,
{ },
4

, ,
, ,
,
, ,
-
, , ( )
,
,
- ,
,
, .

, ,
. ,
, , .
. , ,
, : (1) , (2)
, (3) . ,
(, )
typeName arrayName[arraySize];
(arraySize)
(, 10*sizeof(double)),
.
,
; , . C++ , ..
0 ().
[A] , ,
:
# = sizeof(typeName)* arraySize
[B] () ,
, ( ) :
# = sizeof(arrayName)/ sizeof(typeName)
/C++
. (-)
,
. ,
(), ,
, ,
, .
, ..
. ++ ,
, , ,

( ):
int test[5] = {16,4,-7,251,93};

// Ok
5

int test1[5];
double test2[6] = {5.2,4,3.8};
int test3[ ] = {2,-116,9};
test1 = test;

//
//
//
//
//
//
//

Ok ( )
Ok (3
)
Ok (

)
( !)

++
, ..
, . ,
int arr[3][10];

3 10, .. , 3 10
.
arr[0], arr[1] arr[2],
, 10 . , arr[0] ,
0 () 9, .. arr[0][0], arr[0][1],,
arr[0][9].
++ (STL) Vector. ,
.

( . )

2008 . (Herbert Schildt) C++ Beginners


Guide, , ,
++.
: http://msdn.microsoft.com/en-us/beginner/cc305129.aspx
, - ( 35
.), Visual ++ Express Edition:
http://msdn.microsoft.com/en-us/beginner/bb964629.aspx.
[!]
- ++ (Bjarne Stroustrup) ++
(1995 .),
- (Steve Heller) C++: A Dialog. Programming with C++ Standard Library.
,
++ . A History of
C++: 1979-1991 Evolving a Language In and For the Real World: C++ 1991-2006.
, Internet-, ++:
- Lesson 3. Loops / cprograming.com, 1997-2005.
- Learn C++ Programming Tutorial: Lesson 4 - Loops.
- ++. / IT, 2007.
- online ++ ( ..),
.
6

- ++ Language Tutorial: Arrays / cplusplus.com, 2000-2008.


- C++ Array / CoderSource.net, 2004.
- C++ Programming Style Guidelines, ver. 4.7, Geotechnical Software Services (GSS), 2008.
- R.Cippola. CUED Tutorial Guide to C++ Programming, University of Cambridge, 2002.
- Online C++ Tutorial, 1996-2003.
- [!] Tiobe Programming Language Index ( .),
2008.

(#1)

1.

0 24 ().
.

//
//
//
//
//
//
//
//
//

----------------------------------------------------------------------

: < , , ( XXX)
: Microsoft Visual C++ 2005
: 01.11.2008
: ( ,
, )
------------------------------------------------------------------------

#include <iostream>
using namespace std;
const int arrSize = 25;

//

int main( )
{
double factorials[arrSize];
int i;

// ()

factorials[1] = factorials[0] = 1.0;


// (0!=1, 1!=1)
for(i = 2; i < arrSize; i++)
factorials[i] = i * factorials[i-1];
for(i = 0; i < arrSize; i++)
cout << i << "!= " << fixed << factorials[i] << endl;
// ,
// { }
return 0;
}

, factorials[ ]
double, .. .
int (,
), unsigned int (
). ( double int
double unsigned int factorials)? (!)
, double
.
( )
17! int 14!
unsigned int.
// ----------------------------------------------------------------------//
// (

//
//
//
//

func( ) .1)
: Microsoft Visual C++ 2005
: 05.11.2008
------------------------------------------------------------------------

#include <iostream>
using namespace std;
void func (double [ ]);

// () func( )

const int arrSize = 25;


//
int main( )
{
double factorials[arrSize];
// ()
int i;
factorials[1] = factorials[0] = 1.0;
// (0!=1, 1!=1)
func (factorials);
// func()
for(i = 0; i < arrSize; i++)
cout << i << "!= " << factorials[i] << endl;
// , factorials[0] (
// )
// ,
// { }
return 0;
}
// func( )
void func (double arr[ ])
{
for(int i = 2; i < arrSize; i++)
arr[i] = i * arr[i-1];
return;
}

(. ,
. 4-5 ),
, ,
,
,
,
.
,
<< >>, .. ,
(. stream).
() (endl fixed)
(setprecision),
<iomanip>.
#include <iostream>
#include <iomanip>
using namespace std;
const int arrSize = 25;
//
int main( )
{
... ... ... ... ...
for(i = 0; i < arrSize; i++)
cout << i << "!= " << fixed << setprecision(0) << factorials[i] << endl;
... ... ... ... ...

(. 1(2))

( . 7)

2. (- )

,
( 10- )
.
:

min max
10 (10 )
-> 13 5 37 -20 10 8 54 17 5 27
[min] : -20
[max] : 54
( min max) 15.25

3. (- )
, N1Op1N 2Op 2 ...Op n N n , N i
( i 1, n ) , Opi ( i 1, n )
(+) (-).
:

(, 7-3+5+4-2) <Enter>
-> 8-1+3-2+5
13

-
(, 7-3+5+4-2) <Enter>
-> 6+2*4-1+9
[x] : * .

(, 7-3+5+4-2) <Enter>
-> 6+2-4-1+9
12
9

-
(, 7-3+5+4-2) <Enter>
-> 6-2+12+4-3
[x] : .


4. (- )

, , , ()
- () , ()
- .
- ( char [ ]).
:

:
- 1 -->
- 2 -->
-> 1
: 357
(): 001101010111

PS.

:
- .., .. ++
(http://www.proklondike.com/contentview.php?content=462 )
- ., . ++ (. .)
( http://www.proklondike.com/contentview.php?content=31 )
- . ++ / 7.3 (
++), Price
- ++. ( IT, 2007)
- ++ (,
++).


( )

10

Оценить