Advertisement
IlidanBabyRage

112860.cpp

Sep 26th, 2015
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. typedef vector<int> vi;
  6. typedef long long int lli;
  7.  
  8. int main(){
  9.    
  10.     int n, max, l, r;
  11.     cin >> n;
  12.     max = (n / 4 + (bool)(n % 4)) * 4;
  13.     l = 1;
  14.     r = max;
  15.     while (l < r){
  16.         if (r > n)
  17.             cout << "-";
  18.         else
  19.             cout << r;
  20.         cout << " ";
  21.         if (l > n)
  22.             cout << "-";
  23.         else
  24.             cout << l;
  25.         l += 2;
  26.         r -= 2;
  27.         if (l < r)
  28.             cout << " ";
  29.         else
  30.             cout << endl;
  31.     }
  32.     l = 2;
  33.     r = max - 1;
  34.     while (l < r){
  35.         if (l > n)
  36.             cout << "-";
  37.         else
  38.             cout << l;
  39.         cout << " ";
  40.         if (r > n)
  41.             cout << "-";
  42.         else
  43.             cout << r;
  44.         l += 2;
  45.         r -= 2;
  46.         if (l < r)
  47.             cout << " ";
  48.         else
  49.             cout << endl;
  50.     }
  51.  
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement