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 elemcsere(int[,] tabla, int x1, int y1, int x2, int y2)
- {
- int temp;
- temp = tabla[x1,y1];
- tabla[x1,y1] = tabla[x2,y2];
- tabla[x2, y2] = temp;
- }
- public static void sorcsere(int[,] tabla, int elso, int masodik)
- {
- for(int i = 0; i < 10; i++)
- {
- elemcsere (tabla,elso,i,masodik,i);
- }
- }
- public static void sorcsere(int[,] tabla)
- {
- for(int i = 0; i < 9; i+=2)
- {
- sorcsere (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 tukroz(int[,] tabla)
- {
- for(int i = 0; i < 10; i++)
- {
- for(int s = 1; s <= i; s++)
- {
- int x1 = i-s;
- int y1 = i;
- int x2 = i;
- int y2 = i-s;
- elemcsere (tabla,x1,y1,x2,y2);
- }
- }
- }
- public static void Main (string[] args)
- {
- int[,] tabla = new int[10,10];
- feltolt (tabla);
- kiir(tabla);
- Console.WriteLine ();
- sorcsere (tabla);
- kiir (tabla);
- Console.WriteLine ();
- Console.WriteLine ("Átló összege: "+osszegez (atlo(tabla)));
- Console.WriteLine();
- tukroz (tabla);
- kiir (tabla);
- Console.ReadKey ();
- }
- }
- }
Add Comment
Please, Sign In to add comment