Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2015
643
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. int g_Cnt = 1;
  2.  
  3. void stairs2(int n, int prev_ctep)
  4. {
  5.     cout << "n = " << n << "; prev_ctep = " <<prev_ctep;
  6.     if (n <= 2) {
  7.         if (n < prev_ctep) {
  8.             g_Cnt++;
  9.             cout << " ++";
  10.         }
  11.         cout << endl;
  12.         return;
  13.     }
  14.  
  15.    
  16.     if (n < prev_ctep) {
  17.         g_Cnt++;
  18.         cout << " ++";
  19.     }
  20.     cout << endl;
  21.  
  22.     int d = prev_ctep - n;
  23.     if (prev_ctep == 0 || d > 0)
  24.         d = 0;
  25.     cout << "d=" << d << endl;
  26.     int len = n - floor(n / 2.0);
  27.     if (n % 2 == 0)
  28.         len++;
  29.     for (int i = 1 + abs(d); i <= len; i++) {
  30.         stairs2(i, n - i);         
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement