Welcome

Hi! This blog is for beginners of c++ and java .You can check and pick codes for your programming assignments. This will also help you to understand the concepts of these programming languages. Its all about programming.

0’s-diagonal order(Two dimension ARRAYS)

Tuesday, June 7, 2011

#include <iostream.h>
#include <iomanip.h>
int main(){

    const int rowSize=6;
    const int colSize=6;
    int table [rowSize][colSize];

      for (int row=0; row < rowSize; row++)
      {
          for (int col=0; col < colSize; col++)
          {
          if (row == col)
          table[row][col] = 0;
          else if (row > col)
          table[row][col] = -1;
          else
          table[row][col] = 1;
          } // end for - col
      } // end for - row


      for (row = 0; row < rowSize; row++)
      {
          for (int col =0; col < colSize; col++)
          cout << setw(4) << table[row][col];
          cout << endl;
      } // end for - row - (print)


return 0;
} // end main