Advertisement
Guest User

Untitled

a guest
Nov 25th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.65 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Diagnostics;
  7. using System.Threading;
  8. namespace MultiStream
  9. {
  10.     class Program
  11.     {
  12.         static double S1 = 0.0, S2 = 0.0;
  13.         static int L, H;
  14.         static void Count()
  15.         {
  16.             double P = 1.0;
  17.             for (int i = 2; i <= L; i = i + 2)
  18.             {
  19.                 for (int j = 1; j <= H; j++)
  20.                 {
  21.                     P = (i / 25.0) * (i / 25.0);
  22.                 }
  23.  
  24.                 S1 += P * 4;
  25.                 Thread.Sleep(0);
  26.             }
  27.             S1 += S2;
  28.             Console.WriteLine("Сумма произведений строк: " + S1);
  29.         }
  30.         static void Main(string[] args)
  31.         {
  32.             Console.Write("Line: ");
  33.             L = Convert.ToInt32(Console.ReadLine());
  34.             Console.Write("Hight: ");
  35.             H = Convert.ToInt32(Console.ReadLine());
  36.             var sw = Stopwatch.StartNew();
  37.             Thread myThread = new Thread(Count);
  38.             myThread.Start();
  39.             double S = 0.0;
  40.             double P = 1.0;
  41.             for (int i = 1; i <= L; i = i + 2)
  42.             {
  43.                 for (int j = 1; j <= H; j++)
  44.                 {
  45.                     P = (i / 25.0) * (i / 25.0); ;
  46.                 }
  47.                 S += P * 4;
  48.                 P = 1.0;
  49.                 Thread.Sleep(0);
  50.             }
  51.          
  52.             sw.Stop();
  53.             Console.WriteLine("Время выполнения: " + sw.Elapsed.TotalMilliseconds + "[Mc]");
  54.             Console.ReadKey(true);
  55.         }
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement