mardi 19 mai 2015

How to code this pattern?

Imagine a double dimensional array

for example, if array is

    1      10     20 
    2      11     21
    9      50     100
    100    200    300
    400    500    600

the program should print,

  1               50             100
  2               50             100 
  9               50             100 
 100              50             100
 400              50             100


  9               10             100 
  9               11             100
  9               50             100 
  9               200            100
  9               500            100

  9              50            20
  9              50            21
  9              50            100
  9              50            300
  9              50            600

The number of rows of the array is ALWAYS 5. Number of columns user has to give. It has to be minimum 2. Value of each cell user has to give. The repeating elements are basically 3rd row elements.

Aucun commentaire:

Enregistrer un commentaire