[ create a new paste ] login | about

Link: http://codepad.org/mxMqMueF    [ raw code | output | fork ]

C++, pasted on May 16:
#include <stdio.h>

void m (int n)
{
   for (int i = 0; i < n; ++ i)
   {
      int add = -1;
      int res = i + 1;
      for (int j = 0; j < n; ++ j)
      {
         printf (" %2d", res); // либо если надо запомнить где-то: M[i][j] = res;
         if (res == 1)
            add = 1;
         res += add;
      }
      printf ("\n");
   }
}

int main ()
{
   m (10);
}


Output:
1
2
3
4
5
6
7
8
9
10
  1  2  3  4  5  6  7  8  9 10
  2  1  2  3  4  5  6  7  8  9
  3  2  1  2  3  4  5  6  7  8
  4  3  2  1  2  3  4  5  6  7
  5  4  3  2  1  2  3  4  5  6
  6  5  4  3  2  1  2  3  4  5
  7  6  5  4  3  2  1  2  3  4
  8  7  6  5  4  3  2  1  2  3
  9  8  7  6  5  4  3  2  1  2
 10  9  8  7  6  5  4  3  2  1


Create a new paste based on this one


Comments: