Advertisement
Spocoman

Gymnastics

Sep 20th, 2023 (edited)
657
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.28 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     string country, device;
  8.     cin >> country >> device;
  9.  
  10.     double difficulty = 0, performance = 0;
  11.  
  12.     if (country == "Russia") {
  13.         if (device == "ribbon") {
  14.             difficulty = 9.100;
  15.             performance = 9.400;
  16.         }
  17.         else if (device == "hoop") {
  18.             difficulty = 9.300;
  19.             performance = 9.800;
  20.         }
  21.         else if (device == "rope") {
  22.             difficulty = 9.600;
  23.             performance = 9.000;
  24.         }
  25.     }
  26.     else if (country == "Bulgaria") {
  27.         if (device == "ribbon") {
  28.             difficulty = 9.600;
  29.             performance = 9.400;
  30.         }
  31.         else if (device == "hoop") {
  32.             difficulty = 9.550;
  33.             performance = 9.750;
  34.         }
  35.         else if (device == "rope") {
  36.             difficulty = 9.500;
  37.             performance = 9.400;
  38.         }
  39.     }
  40.     else if (country == "Italy") {
  41.         if (device == "ribbon") {
  42.             difficulty = 9.200;
  43.             performance = 9.500;
  44.         }
  45.         else if (device == "hoop") {
  46.             difficulty = 9.450;
  47.             performance = 9.350;
  48.         }
  49.         else if (device == "rope") {
  50.             difficulty = 9.700;
  51.             performance = 9.150;
  52.         }
  53.     }
  54.  
  55.     double score = difficulty + performance;
  56.  
  57.     cout << fixed << setprecision(3)
  58.         << "The team of " << country << " get " << score << " on " << device << ".\n"
  59.         << setprecision(2) << (20 - score) * 5 << "%\n";
  60.  
  61.     return 0;
  62. }
  63.  
  64. РЕШЕНИЕ С ТЕРНАРЕН ОПЕРАТОР И printf():
  65.  
  66. #include <iostream>
  67. #include <string>
  68.  
  69. using namespace std;
  70.  
  71. int main() {
  72.     string country, device;
  73.     cin >> country >> device;
  74.  
  75.     double score =
  76.         country == "Russia" ?
  77.         (device == "ribbon" ? 9.100 + 9.400 : device == "hoop" ? 9.300 + 9.800 : 9.600 + 9.000) :
  78.         country == "Bulgaria" ?
  79.         (device == "ribbon" ? 9.600 + 9.400 : device == "hoop" ? 9.550 + 9.750 : 9.500 + 9.400) :
  80.         (device == "ribbon" ? 9.200 + 9.500 : device == "hoop" ? 9.450 + 9.350 : 9.700 + 9.150);
  81.  
  82.     printf("The team of %s get %.3f on %s.\n%.2f%%", country.c_str(), score, device.c_str(), (20 - score) * 5);
  83.  
  84.     return 0;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement