Advertisement
Dubwyn

Untitled

Jun 10th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.17 KB | None | 0 0
  1. // zad.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. #include <string>
  7. #include <cmath>
  8.  
  9. using namespace std;
  10.  
  11. int main()
  12. {
  13.     string genre, title;
  14.     int average = 0;
  15.     int arraysize = 10;
  16.     int array[10];
  17.     string movieArray[10];
  18.     for (int i = 0; i < arraysize; i++)
  19.     {
  20.         cout << "Select Genre:  Action, Crime, Adventure" << endl;
  21.     LOOP:
  22.         cin >> genre;
  23.         if (genre == "Action")
  24.         {
  25.             cout << "Choose Title: Arrow, Supergirl" << endl;
  26.             cin >> title;
  27.             movieArray[i] = title;
  28.             if (title == "Arrow")
  29.             {
  30.             LOOP2:
  31.                 cout << "Rate the show: ";
  32.                 cin >> array[i];
  33.                 if (array[i] < 1)
  34.                 {
  35.                     cout << "Invalid rating" << endl;
  36.                     goto LOOP2;
  37.                 }
  38.                 else if (array[i] > 6)
  39.                 {
  40.                     cout << "Invalid rating" << endl;
  41.                     goto LOOP2;
  42.                 }
  43.                 else
  44.                 {
  45.                     cout << "Arrow has been given a rating of " << array[i] << "." << endl;
  46.                 }
  47.             }
  48.             else if (title == "Supergirl")
  49.             {
  50.             LOOP3:
  51.                 cout << "Rate the show: ";
  52.                 cin >> array[i];
  53.                 if (array[i] < 1)
  54.                 {
  55.                     cout << "Invalid rating" << endl;
  56.                     goto LOOP3;
  57.                 }
  58.                 else if (array[i] > 6)
  59.                 {
  60.                     cout << "Invalid rating" << endl;
  61.                     goto LOOP3;
  62.                 }
  63.                 else
  64.                 {
  65.                     cout << "Arrow has been given a rating of " << array[i] << "." << endl;
  66.                 }
  67.             }
  68.         }
  69.         else if (genre == "Crime")
  70.         {
  71.             cout << "Choose Title: Lucifer, Riverdale" << endl;
  72.             cin >> title;
  73.             movieArray[i] = title;
  74.             if (title == "Lucifer")
  75.             {
  76.             LOOP4:
  77.                 cout << "Rate the show: ";
  78.                 cin >> array[i];
  79.                 if (array[i] < 1)
  80.                 {
  81.                     cout << "Invalid rating" << endl;
  82.                     goto LOOP4;
  83.                 }
  84.                 else if (array[i] > 6)
  85.                 {
  86.                     cout << "Invalid rating" << endl;
  87.                     goto LOOP4;
  88.                 }
  89.                 else
  90.                 {
  91.                     cout << "Lucifer has been given a rating of " << array[i] << "." << endl;
  92.                 }
  93.             }
  94.             else if (title == "Riverdale")
  95.             {
  96.             LOOP5:
  97.                 cout << "Rate the show: ";
  98.                 cin >> array[i];
  99.                 if (array[i] < 1)
  100.                 {
  101.                     cout << "Invalid rating" << endl;
  102.                     goto LOOP5;
  103.                 }
  104.                 else if (array[i] > 6)
  105.                 {
  106.                     cout << "Invalid rating" << endl;
  107.                     goto LOOP5;
  108.                 }
  109.                 else
  110.                 {
  111.                     cout << "Riverdale has been given a rating of " << array[i] << "." << endl;
  112.                 }
  113.             }
  114.         }
  115.         else if (genre == "Adventure")
  116.         {
  117.             cout << "Choose Title: Vikings, Krypton" << endl;
  118.             cin >> title;
  119.             movieArray[i] = title;
  120.             if (title == "Vikings")
  121.             {
  122.             LOOP6:
  123.                 cout << "Rate the show: ";
  124.                 cin >> array[i];
  125.                 if (array[i] < 1)
  126.                 {
  127.                     cout << "Invalid rating" << endl;
  128.                     goto LOOP6;
  129.                 }
  130.                 else if (array[i] > 6)
  131.                 {
  132.                     cout << "Invalid rating" << endl;
  133.                     goto LOOP6;
  134.                 }
  135.                 else
  136.                 {
  137.                     cout << "Vikings has been given a rating of " << array[i] << "." << endl;
  138.                 }
  139.             }
  140.             else if (title == "Krypton")
  141.             {
  142.             LOOP7:
  143.                 cout << "Rate the show: ";
  144.                 cin >> array[i];
  145.                 if (array[i] < 1)
  146.                 {
  147.                     cout << "Invalid rating" << endl;
  148.                     goto LOOP7;
  149.                 }
  150.                 else if (array[i] > 6)
  151.                 {
  152.                     cout << "Invalid rating" << endl;
  153.                     goto LOOP3;
  154.                 }
  155.                 else
  156.                 {
  157.                     cout << "Krypton has been given a rating of " << array[i] << "." << endl;
  158.                 }
  159.             }
  160.         }
  161.         else
  162.         {
  163.             cout << "Please select one of the specified genres." << endl;
  164.             goto LOOP;
  165.         }
  166.     }
  167.     int averagearray[10];
  168.     string movieAvarageArray[8];
  169.     for (int i = 0; i < arraysize; i++)
  170.     {
  171.         for (int j = i; j < arraysize; j++)
  172.         {
  173.             if (movieArray[i] == movieArray[j])
  174.             {
  175.                 average = average + (array[i] + array[j]) / 2;
  176.             }
  177.         }
  178.         movieArray[i] = "";
  179.         array[i] = 0;
  180.         movieAvarageArray[i] = movieArray[i];
  181.         averagearray[i] = average;
  182.         average = 0;
  183.     }
  184.     cout << "stanko e gei" << endl;
  185.     for (int i = 0; i < arraysize; ++i)
  186.     {
  187.         for (int j = i + 1; j < arraysize; ++j)
  188.         {
  189.             if (averagearray[i] < averagearray[j])
  190.             {
  191.                 int a = averagearray[i];
  192.                 averagearray[i] = averagearray[j];
  193.                 averagearray[j] = a;
  194.                 string b = movieArray[i];
  195.                 movieArray[i] = movieArray[j];
  196.                 movieArray[j] = b;
  197.             }
  198.         }
  199.     }
  200.     for (int i = 0; i < arraysize; ++i)
  201.     {
  202.         cout << averagearray[i] << " " << movieArray[i] << endl;
  203.     }
  204.     return 0;
  205. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement