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.Diagnostics;
- using System.Threading;
- namespace MultiStream
- {
- class Program
- {
- static double S1 = 0.0, S2 = 0.0;
- static int L, H;
- static void Count()
- {
- double P = 1.0;
- for (int i = 2; i <= L; i = i + 2)
- {
- for (int j = 1; j <= H; j++)
- {
- P = (i / 25.0) * (i / 25.0);
- }
- S1 += P * 4;
- Thread.Sleep(0);
- }
- S1 += S2;
- Console.WriteLine("Сумма произведений строк: " + S1);
- }
- static void Main(string[] args)
- {
- Console.Write("Line: ");
- L = Convert.ToInt32(Console.ReadLine());
- Console.Write("Hight: ");
- H = Convert.ToInt32(Console.ReadLine());
- var sw = Stopwatch.StartNew();
- Thread myThread = new Thread(Count);
- myThread.Start();
- double S = 0.0;
- double P = 1.0;
- for (int i = 1; i <= L; i = i + 2)
- {
- for (int j = 1; j <= H; j++)
- {
- P = (i / 25.0) * (i / 25.0); ;
- }
- S += P * 4;
- P = 1.0;
- Thread.Sleep(0);
- }
- sw.Stop();
- Console.WriteLine("Время выполнения: " + sw.Elapsed.TotalMilliseconds + "[Mc]");
- Console.ReadKey(true);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement