Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- namespace ConsoleApp5
- {
- class Program
- {
- static Random rnd = new Random();
- static public char MostFindedChar(string str)
- {
- int[] arr = new int['z'-'a'+1];
- for (int i = 0; i < str.Length; i++)
- {
- arr['a' - str[i]]++;
- }
- int maxIndex = 0;
- for (int i = 0; i < arr.Length; i++)
- {
- if (arr[i] > arr[maxIndex])
- maxIndex = i;
- }
- return (char)(arr[maxIndex] + 'a');
- }
- static public char[] ArrayGen()
- {
- List<char> list = new List<char>();
- int k;
- do
- {
- Console.WriteLine("Введите к: ");
- } while (!int.TryParse(Console.ReadLine(), out k));
- File.AppendAllText("../../log.txt", $"k = {k}\n");
- for (int i = 'a'; i <= 'z'; i++)
- {
- if(i % k == 0)
- list.Add((char)i);
- }
- return list.ToArray();
- }
- static public int FindCharsCount(string str, char ch1, char ch2)
- {
- int count = 0;
- for (int i = 0; i < str.Length; i++)
- {
- if (str[i] >= ch1 && str[i] <= ch2)
- count++;
- }
- return count;
- }
- static public void CharsCount(string str)
- {
- int[] arr = new int['z' - 'a' + 1];
- for (int i = 0; i < str.Length; i++)
- {
- arr['a' - str[i]]++;
- }
- for (int i = 0; i < arr.Length; i++)
- {
- if(arr[i] == 0)
- continue;
- Console.Write(i + 'a' + ": " + arr[i]);
- }
- }
- static void Main(string[] args)
- {
- int n;
- try
- {
- n = int.Parse(Console.ReadLine());
- if(n < 1)
- throw new ArgumentException("Длина была меньше 1.");
- }
- catch (Exception e)
- {
- Console.WriteLine(e.Message);
- return;
- }
- string str = "";
- for (int i = 0; i < n; i++)
- {
- str += (char)rnd.Next('a', 'z' + 1);
- }
- char[] arr = str.ToCharArray();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement