using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static double parse(string message) { Console.Write(message); string buf = ""; double y = 1, x = 1; Boolean check; ; do { try { check = true; buf = Console.ReadLine(); x = double.Parse(buf); } catch { Console.ForegroundColor = ConsoleColor.Red; Console.Beep(300, 600); Console.WriteLine("Введённые данные неверны, повторите попытку"); Console.ForegroundColor = ConsoleColor.Gray; Console.Write(message); check = false; y++; if (y > 5) { for (int t = 3; t > 0; --t) { Console.Clear(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Программа закроется через {0} с. ", t); System.Threading.Thread.Sleep(1000); } Console.Clear(); Console.ForegroundColor = ConsoleColor.Gray; Environment.Exit(0); } } Console.ForegroundColor = ConsoleColor.Gray; } while (!check && y <= 5); return x; } static void Main(string[] args) { const double k = 1.38e-23, pi = 3.1415,dv =1E-3; double v1 = parse("Введите V1 "); double v2 = parse("Введите V2 "); double m = parse("Введите массу молекулы в г/моль ")/6.02e26; double T = parse("Введите температуру в кельвинах "); double F = 0,integral = 0; double e = Math.Exp(1); for (; v1 <= v2; v1+=dv) { double step = -m * v1 * v1 / 2 / k / T; F = 4 * pi * Math.Pow(m/(Math.PI *2*k*T),1.5) * Math.Pow(v1,2) * Math.Exp(step); integral += F*dv; } integral -= 4 * Math.PI * m * v2 * v2 * Math.Exp(-m * v2 * v2 / 2 / k / T)*(v1-v2); Console.WriteLine("Процент вероятности = " + Math.Round(integral*100,3)); } } }