Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _2DimensionalArray
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[,] A = new int[100,100];
- int i, j;
- int n, m;
- Console.Write("Input the number of the row: ");
- n = int.Parse(Console.ReadLine());
- Console.Write("Input the number of the column: ");
- m = int.Parse(Console.ReadLine());
- for (i = 1; i <= n; i++)
- for (j = 1; j <= m; j++)
- {
- Console.Write("A[{0},{0}]: = ", i, j);
- A[i, j] = int.Parse(Console.ReadLine());
- }
- for (i = 1; i <= n; i++)
- {
- for (j = 1; j <= m; j++)
- Console.Write("{0} ", A[i, j]);
- Console.WriteLine();
- }
- Console.ReadLine();
- int S = 0, S2 = 0;
- for (i = 1; i <= n; i++)
- {
- S = S + A[i, i];
- S2 = S2 + A[i, n - i + 1];
- }
- Console.WriteLine("Sum of the first diagram: {0}", S);
- Console.Write("Sum of the second diagram: {0}", S2);
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement