Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- int main() {
- string country, device;
- cin >> country >> device;
- double difficulty = 0, performance = 0;
- if (country == "Russia") {
- if (device == "ribbon") {
- difficulty = 9.100;
- performance = 9.400;
- }
- else if (device == "hoop") {
- difficulty = 9.300;
- performance = 9.800;
- }
- else if (device == "rope") {
- difficulty = 9.600;
- performance = 9.000;
- }
- }
- else if (country == "Bulgaria") {
- if (device == "ribbon") {
- difficulty = 9.600;
- performance = 9.400;
- }
- else if (device == "hoop") {
- difficulty = 9.550;
- performance = 9.750;
- }
- else if (device == "rope") {
- difficulty = 9.500;
- performance = 9.400;
- }
- }
- else if (country == "Italy") {
- if (device == "ribbon") {
- difficulty = 9.200;
- performance = 9.500;
- }
- else if (device == "hoop") {
- difficulty = 9.450;
- performance = 9.350;
- }
- else if (device == "rope") {
- difficulty = 9.700;
- performance = 9.150;
- }
- }
- double score = difficulty + performance;
- cout << fixed << setprecision(3)
- << "The team of " << country << " get " << score << " on " << device << ".\n"
- << setprecision(2) << (20 - score) * 5 << "%\n";
- return 0;
- }
- РЕШЕНИЕ С ТЕРНАРЕН ОПЕРАТОР И printf():
- #include <iostream>
- #include <string>
- using namespace std;
- int main() {
- string country, device;
- cin >> country >> device;
- double score =
- country == "Russia" ?
- (device == "ribbon" ? 9.100 + 9.400 : device == "hoop" ? 9.300 + 9.800 : 9.600 + 9.000) :
- country == "Bulgaria" ?
- (device == "ribbon" ? 9.600 + 9.400 : device == "hoop" ? 9.550 + 9.750 : 9.500 + 9.400) :
- (device == "ribbon" ? 9.200 + 9.500 : device == "hoop" ? 9.450 + 9.350 : 9.700 + 9.150);
- printf("The team of %s get %.3f on %s.\n%.2f%%", country.c_str(), score, device.c_str(), (20 - score) * 5);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement