Advertisement
CryNext

BetaBuildV0.2

Sep 15th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. #include<iostream>
  2. #include<ctime>
  3. #include<cmath>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     setlocale(LC_ALL, "RUS");
  11.  
  12.     int T, k;
  13.     int k2 = 0;
  14.     int s = 0;
  15.    
  16.  
  17.  
  18.     cout << "Введыть об'эм танкера" << endl;
  19.     cin >> T;
  20.  
  21.  
  22.     cout << "Введыть кылькысть авто" << endl;
  23.     cin >> k;
  24.  
  25.  
  26.     cout << "Введыть об'эм вантажу кожного авто\n" << endl;
  27.  
  28.  
  29.     int* arr = new int[k];
  30.  
  31.     for (int i = 0; i < k; i++)
  32.     {
  33.         cin >> arr[i];
  34.     }
  35.  
  36.    
  37.  
  38.     for (int i = 0; i < k; i++)
  39.     {
  40.  
  41.  
  42.         if (arr[i] <= T)
  43.         {
  44.             k2++;
  45.             s = s + arr[i];
  46.             T = T - arr[i];
  47.  
  48.         }
  49.  
  50.  
  51.         else if (arr[i] > T)
  52.         {
  53.             continue;
  54.         }
  55.  
  56.  
  57.     }
  58.  
  59.     cout << "\nКылькысть авто: " << k2 << endl;
  60.     cout << "\nЗагальний об'эм: " << s << endl;
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement