Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
68
Добавлен:
15.04.2018
Размер:
45.06 Кб
Скачать

Задача 1.

using System;

using System.Collections.Generic;

using System.Text;

namespace Zadacha

{

class Program

{

static void Main(string[] args)

{

do

{

int n, m;

double avr = 0;

do

{

Console.WriteLine("Введите количество строк: ");

} while (!int.TryParse(Console.ReadLine(), out n) || n < 0);

do{

Console.WriteLine("Введите количество столбцов: ");

} while (!int.TryParse(Console.ReadLine(), out m) || m < 0);

double[][] a = MyMethods.Generetor(n, m);

for (int i = 0; i < a.Length; i++)

{

avr = MyMethods.Schetchik(a[i]);

}

MyMethods.Print(a, n, m, avr);

Console.WriteLine("Для повтора нажмите любую клавишу, для выхода нажмите Esc");

} while (Console.ReadKey(true).Key != ConsoleKey.Escape);

}

}

}

Задача 2.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{

int height = 5;

while(true){

Class1 myClass = new Class1();

myClass.alert();

myClass.createMatrix(height);

myClass.setStringsCount(height);

for (int i = 0; i < height; i++)

{

Console.Write("Количество элементов строки "+i+":");

string s = Console.ReadLine();

myClass.setStringListValue(i,Convert.ToInt32(s));

}

myClass.randomMatrix();

myClass.printMatrix();

myClass.printMas();

Console.WriteLine("");

Console.WriteLine("");

Console.WriteLine("");

Console.WriteLine("");

System.Console.ReadKey();

}

}

}

}

Задача 3.

using System;

class Neo

{

public int[,] Zapolnit(int n, int m)

{

int t=0;

int[,] A = new int[n, m];

Random g = new Random

for (int i = 0; i < n; i++)

{

for (int k = 0; k < m; k++)

{

t = g.Next(-20, 21);

A[i, k] = t;

}

}

return A;

}

public void Vivod(int[,] A, int n, int m)

{

for (int i = 0; i < n; i++, Console.WriteLine())

{

for (int k = 0; k < m; k++)

{

Console.Write("{0}\t",A[i,k]);

}

}

}

public void Vivod(int[] A, int n)

{

for (int i = 0; i < n; i++)

{

Console.Write("{0}\t", A[i]);

}

}

public void Sortirovka(ref int[,] A, int n,int m)

{

for (int k = 0; k < m; k++)

{

int[] B= new int[n];

for (int i = 0; i < n; i++)

{

B[i] = A[i, k];

}

Array.Sort(B);

Array.Reverse(B);

for (int i = 0; i < n; i++)

{

A[i, k] = B[i];

}

}

}

}

class pr

{

public static void Main()

{

beg:Console.Clear();

int n, m;

int[,] A;

Console.WriteLine("Вас приветствует программа Массивы!");

Console.WriteLine("Введите количество строк массива");

try

{

n = int.Parse(Console.ReadLine());

}

catch

{

Console.WriteLine("Ошибка ввода!");

goto end;

}

Console.WriteLine("Введите количество столбцов массива");

try

{

m = int.Parse(Console.ReadLine());

}

catch

{

Console.WriteLine("Ошибка ввода!");

goto end;

}

A = new int[n, m];

Console.WriteLine();

Neo S = new Neo();

A=S.Zapolnit(n, m);

S.Vivod(A, n, m);

Console.WriteLine("");

Console.WriteLine("");

S.Sortirovka(ref A, n, m);

S.Vivod(A, n, m);

end:

string k;

Console.WriteLine("Не желаете повторить? Y/N");

k=Console.ReadLine();

if (k == "y" || k == "Y" || k == "yes") goto beg;

else

{

Console.WriteLine("До свидания!");

Console.ReadLine();

}

}

}

Соседние файлы в папке 34