DS02 - s 7 p s [ cfw_ / m st ( Sequential List) X...

Info iconThis preview shows pages 1–16. Sign up to view the full content.

View Full Document Right Arrow Icon
✸✦ ♣✪ ( { [ ( Sequential List) Sequential List) / ( ( Polynomial ADT) Polynomial ADT) ( a ( Sparse Matrix) Sparse Matrix) ( a ( String) String)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
xq± / ³z[” ♥☛
Background image of page 2
/ L±Q” ♥☛ ➐✹ ² / L±Q” ♥☛ ➐✹ / ✱❺ / L±Q” ♥☛ ➐✹ / L±Q” ♥☛ ➐✹
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
x #include <iostream.h> class szcl { int e ; public: szcl ( ) { e = 0; } szcl ( int value ) { e = value ; } int get_value ( ) { return e ; } }
Background image of page 4
main ( ) { szcl a 1[3] = { 3, 5, 7 } , * elem ; for ( int i =0, i <3, i ++ ) cout << a 1[ i ]. get_value ( ) << “\n” ; // } elem a 1 ; for ( int i =0, i <3, i ++ ) { cout << elem get_value ( ) << “\n” ; // } elem ++ ; } return 0 ; }
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
( ( Array Array ) ) e #include <iostream.h> #include <stdlib.h> template <class Type> class Array { Type *elements ; // / int ArraySize ; // e void getArray ( ) ; // / public: Array ( int Size=DefaultSize ) ; Array ( const Array x ) ;
Background image of page 6
~Array ( ) { delete [ ] elements ;} Array <Type> operator = ( const Array <Type> A ) ; Type& operato [ ] ( int i ) ; Array <Type> operator Type * ( ) const { return elements ; } int Length ( ) const { return ArraySize ; } void ReSize ( int sz ) ; }
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
template <class Type> void Array <Type>:: getArray ( ) { // b x elements = new Type [ ArraySize ] ; if ( elements == 0 ) cerr << "Memory Allocation Error" << endl; } /
Background image of page 8
template <class Type> void Array <Type>:: Array ( int sz ) { // e if ( sz <= 0 ) { cerr << "Invalid Array Size" << endl; return; } ArraySize = sz ; getArray ( ) ; }
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
template <class Type> Array <Type>:: Array ( const Array <Type> x ) { // / int n = ArraySize = x.ArraySize ; elements = new Type [ n ] ; if ( elements == 0 ) cerr << "Memory Allocation Error" << endl; Type *srcptr = x.elements ; Type *destptr = elements ; while ( n -- ) * destptr++ = * srcptr++ ; }
Background image of page 10
template <class Type> Type & Array <Type>::operator [ ] ( int i ) { // i if ( i < 0 || i > ArraySize - 1 ) cerr << "Index out of Range" << endl; return element [ i ] ; } / m Position [ i ] = Position [ i - 1] + Number [ i - 1]
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
template <class Type> void Array <Type>:: Resize ( int sz ) { if ( sz >= 0 sz != ArraySize ) { Type * newarray = new Type [ sz ] ; if ( newarray == 0 ) cerr << "Memory Allocation Error" << endl; int n = ( sz <= ArraySize ) ? sz : ArraySize ; Type *srcptr = elements ; Type *destptr = newarray ; while ( n-- ) * destptr++ = * srcptr++ ; delete [ ] elements ; elements = newarray ; ArraySize = sz ; } }
Background image of page 12
pYmº Hs [ * i i . . i i . . j j . . j j Hs[ * k k
Background image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
tmºª* à ± tmº + - = = 0 , ) ( 0 , α ) ( i l i LOC i i LOC 1 LOC ( i ) = LOC ( i - 1 ) + l = α + i*l
Background image of page 14
- - - - - - - - = ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ 1 1 2 1 1 1 0 1 1 2 2 2 1 2 0 2 1 1 2 1 1 1 0 1 1 0 2 0 1 0 0 0 m n a n a n a n a m a
Background image of page 15

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 16
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/30/2011 for the course CS 255 taught by Professor Gangli during the Spring '11 term at Tsinghua University.

Page1 / 82

DS02 - s 7 p s [ cfw_ / m st ( Sequential List) X...

This preview shows document pages 1 - 16. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online