| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- using System;
- using System.IO;
- namespace D6._1
- {
- class Program
- {
- static void Main(string[] args)
- {
- if (args.Length < 1) throw new ArgumentException();
- if (File.Exists(args[0]) == false) throw new FileNotFoundException();
- var freq = new int[8][];
- using (var file = File.OpenText(args[0]))
- {
- while (true)
- {
- var line = file.ReadLine();
- if (line == null) break;
- for (var i = 0; i < 8; i++)
- {
- if (freq[i] == null) freq[i] = new int[26];
- freq[i][line[i] - 'a']++;
- }
- }
- }
- var password = new char[8];
- for (var i = 0; i < 8; i++)
- {
- int max = 0, maxi = 0;
- for (var ci = 0; ci < 26; ci++)
- {
- if (freq[i][ci] > max)
- {
- maxi = ci;
- max = freq[i][ci];
- }
- }
- password[i] = (char)(maxi + 'a');
- }
- Console.WriteLine($"Password is : {string.Join("", password)}");
- }
- }
- }
|