Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

tuna

a guest Dec 7th, 2018 56 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int N = 0;
  9.     int X = 0;
  10.     int P1, P2, P3 = 0;
  11.     int i = 0;
  12.     int razlika = 0;
  13.  
  14.     //broj tuna
  15.     cin >> N;
  16.     //vrijednost s obzirom na koju se mjeri ide li treca procjena
  17.     cin >> X;
  18.  
  19.     do {
  20.         cin >> P1;
  21.         cin >> P2;
  22.         int j = abs(P1 - P2);
  23.         if (j <= X) {
  24.             if (P1 > P2) {
  25.                 razlika += P1;
  26.             }
  27.             else
  28.                 razlika += P2;
  29.         }
  30.         else {
  31.             cin >> P3;
  32.             razlika += P3;
  33.         }
  34.         i++;
  35.     } while (i < N);
  36.  
  37.     cout << razlika;
  38.  
  39.     return 0;
  40. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top