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 ConsoleApp19
- {
- class Program
- {
- private static int[] mas;
- private static int N;
- private static Random r = new Random();
- static int a = 0;
- static int b = 0;
- static void Sort1Up()
- {
- int temp;
- for (int i = 0; i < N; i++) // по выбору
- {
- for (int j = 0; j < N; j++)
- {
- if (mas[i] > mas[j])
- {
- temp = mas[i];
- mas[i] = mas[j];
- mas[j] = temp;
- //a++;
- }
- }
- }
- }
- static void Sort2Up()
- {
- int temp;
- for (int i = 0; i < N; i++) // пузырьковый
- {
- for (int j = i + 1; j < N; j++)
- {
- if (mas[i] > mas[j])
- {
- temp = mas[i];
- mas[i] = mas[j];
- mas[j] = temp;
- //b++;
- }
- }
- }
- }
- static void PrintMatrix()
- {
- for (int i = 0; i < N; i++)
- {
- Console.WriteLine(mas[i].ToString());
- }
- }
- static void FullRandom()
- {
- for (int i = 0; i < N; i++)
- {
- mas[i] = r.Next(0, 100);
- }
- }
- static int MaxArray()
- {
- int max = mas[0];
- for (int i = 0; i < N; i++)
- {
- if (mas[i] > max)
- {
- max = mas[i];
- }
- }
- return max;
- }
- static void Main(string[] args)
- {
- N = int.Parse(Console.ReadLine());
- mas = new int[N];
- Console.WriteLine();
- FullRandom();
- Console.WriteLine(MaxArray() + " Максимальное число");
- Sort1Up();
- PrintMatrix();
- Console.WriteLine();
- mas = new int[N];
- FullRandom();
- Console.WriteLine(MaxArray() + " Максимальное число");
- Sort2Up();
- PrintMatrix();
- //Console.WriteLine(a + " " + b);
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement