Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace hz
- {
- class Program
- {
- static double[] ReadIntArray()
- {
- double[] numsArray;
- bool flag = false;
- do
- {
- flag = true;
- string buff = Console.ReadLine();
- numsArray = new double[buff.Split(' ').Length];
- if (buff.Split(' ').Length > 120 || buff.Split(' ').Length < 1)
- {
- Console.WriteLine("Введите числа ещё раз, позязя!");
- flag = false;
- continue;
- }
- int i = 0;
- foreach (var item in buff.Split(' '))
- {
- if (!double.TryParse(item, out numsArray[i])
- || Math.Abs(numsArray[i]) > 1025)
- {
- Console.WriteLine("Введите числа ещё раз, позязя!");
- flag = false;
- continue;
- }
- i++;
- }
- } while (!flag);
- return numsArray;
- }
- static void ShowGistogramm(double[] numsArray, double min, double max, char symbol)
- {
- //Console.WriteLine(numsArray.Length);
- for (int i = 10; i > 0; i--)
- {
- //Выводим максимум и минимум.
- if (i == 10)
- Console.Write($"{max:f2}\t|\t");
- else if (i == 1)
- Console.Write($"{min:f2}\t|\t");
- else
- Console.Write("\t|\t");
- //Для копипасты 1 2 3 4 5 6 7 8 9
- foreach (var item in numsArray)
- {
- Console.Write(item >= i ? symbol : ' ');
- }
- Console.Write("\r\n");
- }
- }
- static char ReadChar()
- {
- char symbol;
- do
- {
- Console.WriteLine("Соизвольте ввести символ.");
- } while (!char.TryParse(Console.ReadLine(), out symbol));
- Console.WriteLine();
- return symbol;
- }
- static void Main(string[] args)
- {
- //1 2 3 4 5 6 7 8 9 10
- Console.WriteLine("Введите числа через пробел");
- double[] nums = ReadIntArray();
- double[] numsD = new double[nums.Length];
- double maxN = nums.Max();
- double minN = nums.Min();
- for (int i = 0; i < nums.Length; i++)
- {
- numsD[i] = Math.Round(1.0 * (nums[i] - minN) / (maxN - minN) * 10.0);
- }
- ShowGistogramm(numsD, minN, maxN, ReadChar());
- Console.WriteLine("До свидания");
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement