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

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

✸✦ ♣✪ ( { [ ( Sequential List) Sequential List) / ( ( Polynomial ADT) Polynomial ADT) ( a ( Sparse Matrix) Sparse Matrix) ( a ( String) String)

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

View Full Document
xq± / ³z[” ♥☛
/ L±Q” ♥☛ ➐✹ ² / L±Q” ♥☛ ➐✹ / ✱❺ / L±Q” ♥☛ ➐✹ / L±Q” ♥☛ ➐✹

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

View Full Document
x #include <iostream.h> class szcl { int e ; public: szcl ( ) { e = 0; } szcl ( int value ) { e = value ; } int get_value ( ) { return e ; } }
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 ; }

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

View Full Document
( ( 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 ) ;
~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 ) ; }

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

View Full Document
template <class Type> void Array <Type>:: getArray ( ) { // b x elements = new Type [ ArraySize ] ; if ( elements == 0 ) cerr << "Memory Allocation Error" << endl; } /
template <class Type> void Array <Type>:: Array ( int sz ) { // e if ( sz <= 0 ) { cerr << "Invalid Array Size" << endl; return; } ArraySize = sz ; getArray ( ) ; }

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

View Full Document
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++ ; }
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]

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

View Full Document
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 ; } }
pYmº Hs [ * i i . . i i . . j j . . j j Hs[ * k k

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

View Full Document
tmºª* à ± tmº + - = = 0 , ) ( 0 , α ) ( i l i LOC i i LOC 1 LOC ( i ) = LOC ( i - 1 ) + l = α + i*l
- - - - - - - - = ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ 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

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

View Full Document
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
Ask a homework question - tutors are online