Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace atlo
- {
- class MainClass
- {
- public static void feltolt(int[,] tabla)
- {
- for(int i = 0; i < 10; i++)
- {
- for(int j = 0; j < 10; j++)
- {
- int szorzat = (i+1)*(j+1);
- if(szorzat % 2 == 1)
- szorzat++;
- tabla[j,i] = szorzat;
- }
- }
- }
- public static void kiir(int[,] tabla)
- {
- for(int i = 0; i < 10; i++)
- {
- for(int j = 0; j < 10; j++)
- {
- Console.Write ("{0,3} ",tabla[i,j]);
- }
- Console.WriteLine();
- }
- }
- public static void csere(int[,] tabla, int elso, int masodik)
- {
- int temp;
- for(int i = 0; i < 10; i++)
- {
- temp = tabla[elso,i];
- tabla[elso,i] = tabla[masodik,i];
- tabla[masodik, i] = temp;
- }
- }
- public static void csere(int[,] tabla)
- {
- for(int i = 0; i < 9; i+=2)
- {
- csere (tabla,i,i+1);
- }
- }
- public static int[] atlo(int[,] tabla)
- {
- int[] temp = new int[10];
- for(int i = 0; i < 10; i++)
- {
- temp[i] = tabla[i,i];
- }
- return temp;
- }
- public static int osszegez(int[] tomb)
- {
- int sum = 0;
- foreach(int elem in tomb)
- sum += elem;
- return sum;
- }
- public static void Main (string[] args)
- {
- int[,] tabla = new int[10,10];
- feltolt (tabla);
- kiir(tabla);
- Console.WriteLine ();
- csere (tabla);
- kiir (tabla);
- Console.WriteLine ();
- Console.WriteLine ("Átló összege: "+osszegez (atlo(tabla)));
- Console.ReadKey ();
- }
- }
- }
Add Comment
Please, Sign In to add comment