c# - Summing a row from a list -


i want check if row 2 in list match input user.

for example if row 2 following: 1 1 3

and user type in 5

it shall reply user typed in right answer.

the list done, i'm stuck now

static void main(string[] args) {     int x = 3;     int y = 3;     int[,] z = new int[x, y];      random r = new random();     (int = 0; < x; i++)     {         (int j = 0; j < y; j++)         {             z[i, j] = r.next(0, 3);         }     }     (int = 0; < x; i++)     {         (int j = 0; j < y; j++)         {             if (i == 3 && j == 3)             {                 console.write("  ");                 break;             }             else             {                 if (z[i, j] > 9)                     console.write(z[i, j] + " ");                 else                     console.write(z[i, j] + "  ");             }         }         console.writeline();     }     console.readkey();      console.writeline("write summing on row 2 ");     int matain = int.parse(console.readline()); } 

var sum = z[1,0] + z[1,1] + z[1,2];  if (matain == sum)   console.writeline("correct"); else   console.writeline("fail");  console.readkey(); 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -