Advertisement
RakhaPratama

Super Blank!

Jul 17th, 2019
407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void swap(int *xp, int *yp) {
  5.     int temp = *xp;
  6.     *xp = *yp;
  7.     *yp = temp;
  8. }
  9.  
  10. void bubbleSort(int M[], int N) {
  11.    int i, j;
  12.    for (i = 0; i < N-1; i++) {
  13.        for (j = 0; j < N-i-1; j++) {
  14.             if (M[j] > M[j+1]) {
  15.                 swap(&M[j], &M[j+1]);
  16.             }
  17.         }
  18.     }
  19. }
  20.  
  21. int main () {
  22.     int N,A,B,C;
  23.     int MusuhDikalahkan = 0; int SuperDigunakan = 0;
  24.     cin >> N >> A >> B >> C;
  25.     int M[N];
  26.     for (auto i {0}; i < N; i++) {
  27.         cin >> M[i];
  28.     }
  29.    
  30.     bubbleSort(M,N);
  31.  
  32.     for (auto i {0}; i < N; i++) {
  33.         lawan:
  34.         if (A >= M[i]) {
  35.             A = A*C;
  36.             MusuhDikalahkan = MusuhDikalahkan + 1;
  37.         }
  38.         else if (SuperDigunakan == 1) {
  39.             goto skip;
  40.         }
  41.         else if (A < M[i]) {
  42.             A = A + B;
  43.             SuperDigunakan = 0 + 1;
  44.             goto lawan;
  45.         }
  46.         skip:
  47.         continue;
  48.     }
  49.     cout << MusuhDikalahkan << " " << SuperDigunakan;
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement