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;
- using System.IO;
- namespace ConsoleApplication33
- {
- class Program
- {
- static void Main(string[] args)
- {
- double f = 0;
- var path = @"C:/Users/davla/Desktop/4.tif";
- byte[] b = File.ReadAllBytes(path);
- var b1 = b.Distinct();
- foreach (byte a in b1)
- {
- Console.WriteLine("Частота появления числа " + a + " равна " + ((float)b.Count(l => l == a) / (float)b.Length));
- f += -((float)b.Count(l => l == a) / (float)b.Length) * Math.Log((float)b.Count(l => l == a) / (float)b.Length) / Math.Log(2);
- }
- Console.WriteLine("Энтропия равна " + f);
- Console.ReadKey();
- }
- }
- }
- /*using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.IO;
- namespace Structure
- {
- class Student
- {
- string sname, name;
- int date, mark;
- public Student(string a, string b, int c, int d)
- {
- sname = a;
- name = b;
- date = c;
- mark = d;
- }
- public string show()
- {
- return String.Format("Student:\n\tName: {0}\n\tSurname: {1}\n\tDate of birth: {2}\n\tAverage mark: {3}", name, sname, date, mark);
- }
- }
- class Program
- {
- public static void Main(string[] args)
- {
- //File.WriteAllText("F:\\input.txt", "surush surush 1 2");
- // string s;
- /* StreamReader reader = new StreamReader( "F:\\input.txt" );
- StreamWriter writer = new StreamWriter("F:\\Grouop.bin");
- while (true)
- {
- s = Console.ReadLine();
- if (s[0] == ' ')
- break;
- s = s + "\r\n";
- Console.WriteLine(s);
- writer.WriteLine(s);
- }
- writer.Close();
- string[] lines = File.ReadAllLines("F:\\Grouop2.bin");
- StreamWriter writer = new StreamWriter("F:\\output.txt");
- for (int i = 0; i < lines.Length; i++)
- {
- Console.WriteLine(lines[i]);
- writer.WriteLine(lines[i]);
- }
- writer.Close();
- Console.Write("Press any key to continue . . . ");
- Console.ReadKey(true);
- }
- }
- }*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement