diagonal numbers in string 10*10

Can someone help me with a program, I have to make a 10*10 diagonal program for numbers.It has to look liek this.
0 1 3 6 10 15 21 28 36 45
2 4 7 11 16 22 29 37 46 55
5 8 12 17 23 30 38 47 56 64
9 13 18 24 31 39 48 57 65 72
14 19 25 32 40 49 58 66 73 79
20 26 33 41 50 59 67 74 80 85
27 34 42 51 60 68 75 81 86 90
35 43 52 61 69 76 82 87 91 94
44 53 62 70 77 83 88 92 95 97
54 63 71 78 84 89 93 96 98 99
closed account (oy0Gy60M)
Can someone help me with a program, I have to make a 10*10 diagonal program for numbers.It has to look liek this.

Sorry, I still don't understand the logic of the table given. Could you elaborate on that more?
Look at nested for loops and arrays.
So I have to make like a chess table but it's a string 10*10,and i have to put numbers 0-100 and they have to be diagonal.This has to be the output:

0 1 3 6 10 15 21 28 36 45
2 4 7 11 16 22 29 37 46 55
5 8 12 17 23 30 38 47 56 64
9 13 18 24 31 39 48 57 65 72
14 19 25 32 40 49 58 66 73 79
20 26 33 41 50 59 67 74 80 85
27 34 42 51 60 68 75 81 86 90
35 43 52 61 69 76 82 87 91 94
44 53 62 70 77 83 88 92 95 97
54 63 71 78 84 89 93 96 98 99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
   const int SIZE = 10;
   int m[SIZE][SIZE];
   int i, j, diag, jmin, jmax;
   int count = 0;
   
   for ( diag = 0; diag < 2 * SIZE - 1; diag++ )
   {
      jmax = diag;   if ( jmax >= SIZE ) jmax = SIZE - 1;
      jmin = diag - jmax;
      for ( j = jmax; j >= jmin; j-- )
      {
         i = diag - j;
         m[i][j] = count;
         count++;
      }
   }

   for ( i = 0; i < SIZE; i++ )
   {
      for ( j = 0; j < SIZE; j++ ) cout << setw(3) << m[i][j] << " ";
      cout << endl;
   }
}
thank you.
Topic archived. No new replies allowed.