Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp1
- {
- class Program
- {
- public static void Main(string[] args)
- {
- init();
- }
- public static void init()
- {
- int[] p;
- int[,] W; //DISDIASTATOS PINAKAS
- int epilogi;
- p = Input(); // p[4,6]
- W = Gemisma(p[0], p[1]);
- epilogi = InputMenou(Menou());
- if(epilogi == 1)
- {
- W = AristeriDiagonios(W);
- }
- else if (epilogi ==2)
- {
- W = DeksiaDiagonios(W);
- }
- else if (epilogi == 3)
- {
- W = AllagiGrammis(W);
- }
- else if (epilogi == 4)
- {
- W = AllagiStilis(W);
- }
- OutPut(W);
- }
- public static int[] Input()
- {
- int[] p = new int[2];
- Console.WriteLine("Dose arithmo grammon");
- p[0] = Convert.ToInt32(Console.ReadLine()); //grammes
- Console.WriteLine("Dose arithmo katheton");
- p[1] = Convert.ToInt32(Console.ReadLine()); //stiles
- return p;
- }
- public static int[,] Gemisma(int row, int col)
- {
- int[,] p = new int[row, col];
- for (int i = 0; i < p.GetLength(0); i++)
- {
- for (int j = 0; j < p.GetLength(1); j++)
- {
- p[i, j] = 0;
- }
- }
- return p;
- }
- public static int Menou()
- {
- Console.WriteLine("1- Aristeri Diagonios");
- Console.WriteLine("2- Deksia Diagonios");
- Console.WriteLine("3- Grammi");
- Console.WriteLine("4- Stilli");
- return 4;
- }
- public static int InputMenou(int a)
- {
- int epilogi;
- Console.WriteLine("Epelekse anamesa stis {0} katigories", a);
- epilogi = Convert.ToInt32(Console.ReadLine()); //epelekse o xristis
- return epilogi;
- }
- public static int[,] AristeriDiagonios(int[,] p)
- {
- for (int i = 0; i < p.GetLength(0); i++)
- {
- for (int j = 0; j < p.GetLength(1); j++)
- {
- if(i==j)
- {
- p[i, j] = 1;
- }
- }
- }
- return p;
- }
- public static int[,] DeksiaDiagonios(int[,] p)
- {
- for (int i = 0; i < p.GetLength(0); i++)
- {
- for (int j = 0; j < p.GetLength(1); j++)
- {
- if ((i+j) == p.GetLength(0)-1)
- {
- p[i, j] = 1;
- }
- }
- }
- return p;
- }
- public static int[,] AllagiGrammis(int[,] p)
- {
- for (int i = 0; i < p.GetLength(0); i++)
- {
- for (int j = 0; j < p.GetLength(1); j++)
- {
- if (i == 0)
- {
- p[i, j] = 1;
- }
- }
- }
- return p;
- }
- public static int[,] AllagiStilis(int[,] p)
- {
- for (int i = 0; i < p.GetLength(0); i++)
- {
- for (int j = 0; j < p.GetLength(1); j++)
- {
- if (j ==0)
- {
- p[i, j] = 1;
- }
- }
- }
- return p;
- }
- public static void OutPut(int[,] p)
- {
- for (int i = 0; i < p.GetLength(0); i++)
- {
- for (int j = 0; j < p.GetLength(1); j++)
- {
- Console.Write("{0,2}", p[i, j]);
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement