Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.07 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4. #include <fstream>
  5. #include <vector>
  6. #include <algorithm>
  7. #include <cmath>
  8. using namespace std;
  9. //2
  10.  
  11. /*
  12. class guitar {
  13. private:
  14.     string mod, prod, type, sim_type;
  15.     int raod, price;
  16.  
  17. public:
  18.     guitar(string mod,  string prod,    int raod,   string type,    string sim_type,    int price)
  19.     {
  20.         this->mod = mod;
  21.         this->prod = prod;
  22.         this->raod = raod;
  23.         this->type = type;
  24.         this->sim_type = sim_type;
  25.         this->price = price;
  26.     }
  27.     int get_raod() {
  28.         return raod;
  29.     }
  30.     string get_mod() {
  31.         return mod;
  32.     }
  33.     string get_prod() {
  34.         return prod;
  35.     }
  36.     string get_type() {
  37.         return type;
  38.     }
  39.     string get_sim_type() {
  40.         return sim_type;
  41.     }
  42.     int get_price() {
  43.         return price;
  44.     }
  45.     ~guitar() {
  46.         cout << "program end........";
  47.     }
  48. };
  49. int main() {
  50.     string mod, prod, type, sim_type;
  51.     int raod, price;
  52.     ifstream ifs("guitars.txt");
  53.  
  54.     vector<guitar> guitars;
  55.     while(ifs >> mod >> prod >> sim_type >> raod >> price)
  56.         {
  57.           //    guitar(string mod,  string prod,    int raod,   string type,    string sim_type,    int price)
  58.         guitar x(mod, prod, raod, type, sim_type, price);
  59.         guitars.push_back(x);
  60.     }
  61.     for (int i = 0; i < guitars.size(); ++i) {
  62.         cout << guitars[i].get_prod() << " "
  63.              << guitars[i].get_price() << " "
  64.              << guitars[i].get_mod()<<" "
  65.              << guitars[i].get_raod() <<" "
  66.              << guitars[i].get_sim_type() << endl;
  67.     }
  68. }
  69. */
  70. //3
  71. /*
  72. class smartphone {
  73. private:
  74.     string mod, prod, op_sys, op_sys_type;
  75.     int memory, ram;
  76.  
  77. public:
  78.     smartphone(string mod,  string prod,    int memory, string op_sys,  string op_sys_type, int ram)
  79.     {
  80.         this->mod = mod;
  81.         this->prod = prod;
  82.         this->memory = memory;
  83.         this->op_sys = op_sys;
  84.         this->op_sys_type = op_sys_type;
  85.         this->ram = ram;
  86.     }
  87.     int get_memory() {
  88.         return memory;
  89.     }
  90.     string get_mod() {
  91.         return mod;
  92.     }
  93.     string get_prod() {
  94.         return prod;
  95.     }
  96.     string get_op_sys() {
  97.         return op_sys;
  98.     }
  99.     string get_op_sys_type() {
  100.         return op_sys_type;
  101.     }
  102.     int get_ram() {
  103.         return ram;
  104.     }
  105.     ~smartphone() {
  106.         cout << "program end........";
  107.     }
  108. };
  109. int main() {
  110.     string mod, prod, op_sys, op_sys_type;
  111.     int memory, ram;
  112.     ifstream ifs("smartphones.txt");
  113.  
  114.     vector<smartphone> smartphones;
  115.     while(ifs >> mod >> prod >> op_sys_type >> memory >> ram)
  116.         {
  117.         smartphone x(mod, prod, memory, op_sys, op_sys_type, ram);
  118.         smartphones.push_back(x);
  119.     }
  120.     for (int i = 0; i < smartphones.size(); ++i) {
  121.         cout << smartphones[i].get_prod() << " "
  122.              << smartphones[i].get_ram() << " "
  123.              << smartphones[i].get_mod()<<" "
  124.              << smartphones[i].get_memory() <<" "
  125.              << smartphones[i].get_op_sys_type() << endl;
  126.     }
  127. }
  128. */
  129. //4
  130. /*
  131. class light {
  132. private:
  133.     string type;
  134.     int raod, length, d_or_w;
  135.  
  136. public:
  137.     light(string type,int raod, int length , int d_or_w)
  138.     {
  139.         this->type = type;
  140.         this->raod = raod;
  141.         this->length = length;
  142.         this->d_or_w=d_or_w;
  143.     }
  144.     int get_d_or_w()
  145.     {
  146.         if (type=="mrgvali")
  147.         {
  148.             cout<<d_or_w;
  149.         }else
  150.         {
  151.             cout<<length<<" "<<d_or_w;
  152.         }
  153.     }
  154.     int get_raod() {
  155.         return raod;
  156.     }
  157.     string get_type() {
  158.         return type;
  159.     }
  160.     int get_length() {
  161.         return length;
  162.     }
  163.     ~light() {
  164.         cout << "program end........";
  165.     }
  166. };
  167. int main() {
  168.     string type;
  169.     int raod, length, d_or_w;
  170.     ifstream ifs("lights.txt");
  171.  
  172.     vector<light> lights;
  173.     while(ifs >> type >> raod >> length >> d_or_w)
  174.         {
  175.         light x(type, raod, length , d_or_w);
  176.         lights.push_back(x);
  177.     }
  178.     for (int i = 0; i < lights.size(); ++i) {
  179.         cout << lights[i].get_length() << " "
  180.              << lights[i].get_type()<<" "
  181.              << lights[i].get_raod() <<" "
  182.              <<lights[i].get_d_or_w()<<endl;
  183.              
  184.     }
  185. }
  186. */
  187. //5
  188. /*
  189. class continent {
  190. private:
  191.     string name, mosazghvre;
  192.     int fartobi, mos;
  193.  
  194. public:
  195.     continent(string name,int fartobi,  int mos , string mosazghvre )
  196.     {
  197.         this->name = name;
  198.         this->fartobi = fartobi;
  199.         this->mos = mos;
  200.         this->mosazghvre=mosazghvre;
  201.     }
  202.    
  203.     int get_fartobi() {
  204.         return fartobi;
  205.     }
  206.     string get_name() {
  207.         return name;
  208.     }
  209.     int get_mos() {
  210.         return mos;
  211.     }
  212. string get_mosazghvre()
  213. {
  214.     return mosazghvre;
  215. }
  216.     ~continent() {
  217.         cout << "program end........";
  218.     }
  219. };
  220. bool mysort( continent a, continent b)
  221. {
  222.     return a.get_fartobi()<b.get_fartobi();
  223. }
  224. int main() {
  225.     string name,mosazghvre;
  226.     int fartobi, mos;
  227.     ifstream ifs("continents.txt");
  228.  
  229.     vector<continent> continents;
  230.     while(ifs >> name >> fartobi >> mos >> mosazghvre)
  231.         {
  232.         continent x(name, fartobi, mos, mosazghvre );
  233.         continents.push_back(x);
  234.     }
  235.     sort(continents.begin(), continents.end(),mysort);
  236.     for (int i = 0; i < continents.size(); ++i) {
  237.         cout << continents[i].get_mos() << " "
  238.              << continents[i].get_name()<<" "
  239.              << continents[i].get_fartobi() <<" "
  240.              <<continents[i].get_mosazghvre()<<" "<<endl;
  241.              
  242.              
  243.     }
  244. }
  245. */
  246. //6
  247. /*
  248. class planet {
  249. private:
  250.     string name, system;
  251.     int dashoreba, raod, galaxy;
  252.  
  253. public:
  254.     planet(string name,int dashoreba,   int raod , string system, int galaxy )
  255.     {
  256.         this->name = name;
  257.         this->dashoreba = dashoreba;
  258.         this->raod = raod;
  259.         this->system=system;
  260.         this->galaxy;
  261.     }
  262.    
  263.     int get_dashoreba() {
  264.         return dashoreba;
  265.     }
  266.     string get_name() {
  267.         return name;
  268.     }
  269.     int get_raod() {
  270.         return raod;
  271.     }
  272. string get_system()
  273. {
  274.     return system;
  275. }
  276.     int get_galaxy()
  277.     {
  278.         return galaxy;
  279.     }
  280.  
  281.     ~planet() {
  282.         cout << "program end........";
  283.     }
  284. };
  285. bool mysort( planet a, planet b)
  286. {
  287.     return a.get_dashoreba()<b.get_dashoreba();
  288. }
  289. bool sort_raod(planet a, planet b)
  290. {
  291.     return a.get_raod()<b.get_raod();
  292. }
  293. int main() {
  294.     string name, system;
  295.     int dashoreba, raod, galaxy;
  296.  
  297.     ifstream ifs("planets.txt");
  298.  
  299.     vector<planet> planets;
  300.     while(ifs >> name >> dashoreba >> raod >> system>>galaxy)
  301.         {
  302.         planet x(name, dashoreba, raod, system ,galaxy);
  303.         planets.push_back(x);
  304.     }
  305.     sort(planets.begin(), planets.end(),mysort);
  306.     sort(planets.begin(), planets.end(),sort_raod);
  307.     for (int i = 0; i < planets.size(); ++i) {
  308.         cout << planets[i].get_raod() << " "
  309.              << planets[i].get_name()<<" "
  310.              << planets[i].get_dashoreba() <<" "
  311.              <<planets[i].get_system()<<" "
  312.              <<planets[i].get_galaxy()<<endl;
  313.              
  314.              
  315.     }
  316. }
  317. */
  318. //7
  319. /*
  320. class dot {
  321. private:
  322.     int x, y, z;
  323.  
  324. public:
  325.     dot(int x,  int y , int z )
  326.     {
  327.        
  328.         this->x = x;
  329.         this->y = y;
  330.         this->z;
  331.     }
  332.    
  333.     int get_x() {
  334.         return x;
  335.     }
  336.     int get_y() {
  337.  
  338.         return y;
  339.     }
  340.     int get_z()
  341.     {
  342.         return z;
  343.     }
  344.  
  345.     ~dot() {
  346.         cout << "program end........";
  347.     }
  348.  
  349.     int get_position()
  350. {
  351.     return sqrt(x*x+y*y+z*z);
  352. }
  353. };
  354.  
  355. int my_sort(dot a, dot b)
  356. {
  357. return a.get_position()>b.get_position();
  358. }
  359. int main() {
  360.     int x, y, z;
  361.     vector<dot> dots;
  362.     while(cin>>x >> y >>z)
  363.         {
  364.         dot t( x, y,z);
  365.         dots.push_back(t);
  366.     }
  367.     sort(dots.begin(), dots.end(), my_sort);
  368.     for (int i = 0; i < dots.size(); ++i) {
  369.         //აq ფაილებში გადაანაწილე რა არის ვერ მივხვდი ,ანუ სხვადასხვა ფაილში ჩავწერო თითოეული თუ რა ვარიანტიa? ვაფშე ძაან დებილური ამოცანაა ეს -__-
  370.              
  371.     }
  372. }
  373. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement