Camp €µ„¹¼±ƒ¯±‚...

download Camp €µ„¹¼±ƒ¯±‚  ±½µ»»®½¹‚ ”¹±³‰½¹ƒ¼Œ‚  »·†¹®‚

of 32

  • date post

    21-Jan-2016
  • Category

    Documents

  • view

    27
  • download

    0

Embed Size (px)

description

Camp προετοιμασίας Πανελλήνιος Διαγωνισμός Πληροφορικής Αθήνα 11-15 Μαρτίου, 2013. C++ STL, Στρατηγική ανάπτυξης προγράμματος την ώρα του διαγωνισμού. Κηπουρίδης Βαγγέλης kipoujr@hotmail.com. Συνοπτικά. Δε θα ασχοληθούμε με πολύπλοκα ζητήματα της γλώσσας. - PowerPoint PPT Presentation

Transcript of Camp €µ„¹¼±ƒ¯±‚...

  • Camp 11-15 , 2013C++ STL,

    kipoujr@hotmail.com

  • . . : .

  • Pascal :(+) ( - ) , C :(+) ( - ) C++ :(+) STL ( Standard Template Library )( - )

  • Pascal, . C STL C++.A STL standard C. STL ( quicksort ).

  • . blocks ., . 20 , .

  • . 1 i j.

    curr_node = par[ neib ]; x = A[y];( u += v )

  • STL #include #define, using namespace std; container container container_name. .. : vector nodes;set< pair > distances;map< int, int > compressed;

  • STL Pairs #include pair. ..pair val; val.first, val.second pair mp ( value1, value2 ). ..val = mp ( 5, 10 ) // val.first=5,val.second=10;

  • STL Pairs :#define X first#define Y second#define mp make_pairtypedef pair pii; val.X = 5;val.Y = moxosval = mp ( 5, moxos );

  • STL Pairs struct 2 ; pairs operators . pair1.X pair2.X , , pair1.Y pair2.Y pair dijkstra, ' . pii dist, dist.X dist.Y .

  • Vectors arrays. #include vector 30 integers :vector example(30); // :printf (%d\n, example[0] );

  • Vectors : !vector example(30);example.push_back(5);example.push_back(10);printf (%d\n, example[31]); // 10

  • Vectors vector, push_back. adjacency list. for ( i=0; i< e.size(); ++i ) i
  • Set , . #include . 2 5, 1 . multiset ( #include )

  • Set set< type > S. ..set S;multiset multiS; insert. S.insert ( 5 ); iterator ( pointer ) set::iterator pos;

  • Set :pos = S.begin(); // pos iterator set::iterator pos; for ( pos = S.begin(); pos != S.end(); ++pos ) { printf (%d\n, *pos ); // *pos } S.end() set.

  • Set S.end() set. : :set::iterator pos = S.end(); --pos; // , : pos = S.find(5); if ( pos == S.end() ) { printf (Value not found \n); }

  • Set ( container )S.size() , setS.empty() bool , set.

  • Map , index , . ..my_map[ moxos ] = Way of debuggingmy_map[ 999999999999LL ] = ''. key ( moxos ) ( Way of debugging ). #include map< key_type, value_type > map_name;

  • Map key, my_map[ key ], !' : if ( my_map.find ( key ) != my_map.end() )

  • Map ... , frequency[ A[i] ]++ frequency A[i]. , O ( logN ), factor. , STL, , .

  • Algorithms #include , sort. .

  • Algorithmsmin( var1, var2 ) max ( var1, var2 ) . , .swap ( var1, var2 ); , , 2 .

  • Algorithmssort( begin_pointer, end_pointer ) vector :sort ( my_vec.begin(), my_vec.end() ); 0 -1 ( 1 ) :sort ( Array, Array+N ); // 0 -1 sort ( Array+1, Array+N+1 ); // 1

  • Algorithms :sort ( interval+1, interval+N+1, smaller );

    comp :bool smaller ( Interval a, Interval b ) { return a.left < b.left; // return a.left > b.left }

  • Algorithmsnext_permutation ( first, last ); prev_permutation ( first, last ); next_permutation (first, last, smaller ); prev_permutation (first, last, smaller ); / ( ).

  • Algorithms false ( ) . :sort ( A+1, A+N+1, comp );do { function ( A ); } while ( next_permutation ( A+1, A+N+1, comp ) );

  • ' . !

  • 1 , 0 -1.

  • Debugger, . printf. debug. .. printf (moxos %d\n, steps);

  • ! .

  • ;, , ! . , debugging .