Advertisement
Spocoman

06. World Swimming Record

Sep 3rd, 2023
811
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main() {
  6.     double record, distance, secondsToMeter;
  7.     cin >> record >> distance >> secondsToMeter;
  8.  
  9.     double score = distance * secondsToMeter + floor(distance / 15) * 12.5;
  10.  
  11.     cout.setf(ios::fixed);
  12.     cout.precision(2);
  13.  
  14.     if (score >= record) {
  15.         cout << "No, he failed! He was " << score - record << " seconds slower." << endl;
  16.     }
  17.     else {
  18.         cout << "Yes, he succeeded! The new world record is " << score << " seconds." << endl;
  19.     }
  20.  
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement