Advertisement
donlk

C++ vizsga-feladat

Jun 23rd, 2011
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.19 KB | None | 0 0
  1. #include <iostream>
  2. #include <complex>
  3. #include "setseq.h"
  4. #include <algorithm>
  5. #include <list>
  6. #include <numeric>
  7. #include <vector>
  8. #include "setseq.h"
  9. #include <deque>
  10. #include <string>
  11.  
  12. const int max = 1000;
  13.  
  14. typedef std::complex<int> Complex;
  15.  
  16. int main()
  17. {
  18.   int yourMark = 1;
  19.  
  20.   SetSequence<std::list<int>, int> listset;
  21.   SetSequence<std::deque<std::string>, std::string> deqset;
  22.  
  23.   SetSequence<std::vector<Complex>, Complex> vecset;
  24.   vecset.push_back( Complex( 1, 2 ) );
  25.  
  26.   SetSequence<std::vector<Complex>, Complex> s;
  27.   s.push_back( Complex( 3, 1 ) );
  28.   s.push_back( Complex( 1, 2 ) );
  29.   vecset.set_union( s );
  30.  
  31.   deqset.push_back( "Hello" );
  32.   deqset.push_front( "World" );
  33.   deqset.push_front( "Hello" );
  34.  
  35.   for( int i = 0; i < max; ++i )
  36.   {
  37.     listset.push_front( i + 1 );
  38.     listset.push_front( i );
  39.   }
  40.  
  41.   const SetSequence<std::list<int>, int> clistset = listset;
  42.   const SetSequence<std::deque<std::string>, std::string> cdeqset = deqset;
  43.  
  44.   if ( sizeof( deqset ) != sizeof( listset ) &&
  45.        1 + max == clistset.size() &&
  46.        1 == clistset.back() &&
  47.        "World" == cdeqset.front() )
  48.   {
  49.     yourMark = vecset.size();
  50.   }
  51.  
  52.   for( int i = 0; i < max; ++i )
  53.   {
  54.     listset.erase( i );
  55.   }
  56.  
  57.   if ( 0 == listset.count( max / 2 ) && 1 == listset.count( max ) )
  58.   {
  59.     yourMark = listset.size() + cdeqset.size();
  60.   }
  61.  
  62.   SetSequence< std::vector<int> > vset;
  63.   vset.push_back( 1 );
  64.   vset.push_back( 3 );
  65.   vset.push_back( 3 );
  66.   SetSequence< std::vector<int> >::const_iterator i =
  67.     std::find( vset.begin(), vset.end(), max );
  68.   if ( i == vset.end() )
  69.   {
  70.     yourMark = std::accumulate( vset.begin(), vset.end(), 0 );
  71.   }
  72.  
  73.   SetSequence< std::list<Complex> > lcompset;
  74.   SetSequence< std::deque<Complex> > dcompset;
  75.   lcompset.push_front( Complex( 1, 2 ) );
  76.   lcompset.push_front( Complex( 3, 1 ) );
  77.   dcompset.push_back( Complex( 3, 1 ) );
  78.   dcompset.push_back( Complex( 2, 4 ) );
  79. /*
  80.   if ( lcompset == vecset && lcompset != dcompset )
  81.   {
  82.     yourMark = lcompset.size() + dcompset.size() + listset.size();
  83.   }
  84.   */
  85.   std::cout << "Your mark is " << yourMark;
  86.   std::endl( std::cout );
  87.   system("pause");
  88.  
  89.  
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement