Advertisement
skb50bd

UVa 11875 Brick Game

Aug 28th, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void swap(int &a, int &b) {
  5.     int temp = a;
  6.     a = b;
  7.     b = temp;
  8. }
  9.  
  10. int main() {
  11.     int T, N;
  12.     int AoP[10];
  13.     cin >> T;
  14.     for(int i = 1; i <= T; i++) {
  15.         cin >> N;
  16.         for(int j = 0; j < N; j++)
  17.             cin >> AoP[j];
  18.         for(int j = 0; j < N - 1; j++)
  19.             for(int k = j + 1; k < N; k++)
  20.                 if(AoP[j] > AoP[k])
  21.                     swap(AoP[j], AoP[k]);
  22.         cout << "Case " << i << ": " << AoP[N / 2] << endl;
  23.     }
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement