trojanxem

Untitled

Jun 17th, 2013
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.92 KB | None | 0 0
  1.     #include <iostream>
  2.     #include  <List>
  3.     #include  <string.h>
  4.     #include <map>
  5.     #include  <vector>
  6.     #include  <aLgorithm>
  7.     using namespace std;
  8.      template <typename T>
  9.      class Punkt
  10.      {
  11.         public:
  12.            Punkt( T argX, T argY, T argZ )
  13.            : x(argX), y(argY), z(argZ)
  14.            { }
  15.  
  16.            T x, y, z;
  17.      };
  18.     template <class parametr1, class parametr2>
  19.     parametr1 mnozenie (parametr1 argument1, parametr2 argument2)
  20.     {
  21.         if( argument1 * argument2 > 1)
  22.         {
  23.             return (argument1 + argument2);
  24.         }
  25.         else
  26.         {
  27.             return 112;
  28.         }
  29.         if( argument1 * argument2 == 0)
  30.         {
  31.             return 0;
  32.         }
  33.         else
  34.         {
  35.  
  36.             return 1;
  37.         }
  38.     }
  39.      typedef Punkt<int> PunktInt;
  40.      typedef Punkt<unsigned> PunktUInt;
  41.      typedef Punkt<float> PunktFloat;
  42.  
  43.      int main()
  44.      {
  45.         PunktInt A(5,-15,0);
  46.         PunktUInt B(6,10,5);
  47.     /*1*/
  48.     cout<<"1"<<endl;
  49.        cout << "A(" << A.x << "," << A.y << "," << A.z << ")" <<endl;            // Efekt wywoListaania metody 1
  50.        cout << "B(" << B.x << "," << B.y << "," << B.z << ")" <<endl;
  51.         cout <<endl;
  52.          cout <<endl;
  53.  
  54.        /*  3 i 8  */
  55.        cout<<" 3 "<<endl;
  56.        list<int> Lista;
  57.        Lista.push_back(0);
  58.        Lista.push_front(0);
  59.        Lista.insert(++Lista.begin(),2);
  60.        Lista.push_back(5);
  61.        Lista.push_back(6);
  62.        list<int>::iterator i;
  63.        cout << "3" <<endl;
  64.        for(i=Lista.begin(); i != Lista.end(); ++i)
  65.        {
  66.            cout << *i << " ";
  67.        }
  68.        Lista.sort();
  69.        cout << "Sortowanie" <<endl;
  70.         for(i=Lista.begin(); i != Lista.end(); ++i)
  71.        {
  72.            cout << *i << " ";
  73.        }
  74.        cout <<endl;
  75.        cout <<endl;
  76.         cout << "Po sortowaniu  wygListaada to tak" <<endl;
  77.        cout << "Minimum ze stListaa: " <<endl;
  78.        cout << "min(3.14,2.73)==" << min(3.14,2.73) << '\n';
  79.        cout <<endl;
  80.         cout <<endl;
  81.          /*2*/
  82.          cout<<" 2 "<<endl;
  83.        cout << mnozenie(10,  0) <<endl;
  84.         cout <<endl;
  85.          cout <<endl;
  86.           /*  4 */
  87.         map<int, string> Videoteka;
  88.         cout << " 4" <<endl;
  89.        Videoteka[1] = "Kochaj i tancz";
  90.        Videoteka[7] = "Star wars";
  91.        Videoteka[8] = "Matrix";
  92.        Videoteka[5] = "Dirty Dancing";
  93.        Videoteka[6] = "KogieLista MogieLista";
  94.           cout << "Map size: " << Videoteka.size() <<endl;
  95.        for( map<int,string>::iterator jj=Videoteka.begin(); jj!=Videoteka.end(); ++jj)
  96.        {
  97.            cout << (*jj).first << ": " << (*jj).second <<endl;
  98.        }
  99.         cout <<endl;
  100.          cout <<endl;
  101.  
  102.        /* piąte */
  103.        vector<string> zadaniepiate;
  104.        cout << " 5" <<endl;
  105.     zadaniepiate.push_back("The number is 10");
  106.     zadaniepiate.push_back("The number is 20");
  107.     zadaniepiate.push_back("The number is 30");
  108.     cout << "PetListaa po indeksie <Vektor>:" <<endl;
  109.     int jj;
  110.     for(jj=0; jj < zadaniepiate.size(); jj++)
  111.     {
  112.     cout << zadaniepiate[jj] <<endl;
  113.     }
  114.     cout << endl << "StaListay iterator:" <<endl;
  115.     vector<string>::const_iterator cjj;
  116.     for(cjj=zadaniepiate.begin(); cjj!=zadaniepiate.end(); cjj++)
  117.      {
  118.       cout << *cjj <<endl;
  119.       }
  120.        cout <<endl;
  121.         cout <<endl;
  122.  
  123.  
  124.  
  125.  
  126.        return 0;
  127.  
  128.  
  129.  
  130.      }
Advertisement
Add Comment
Please, Sign In to add comment