Advertisement
MladenKarachanov

Не е решена Histogram

Mar 13th, 2025
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.74 KB | None | 0 0
  1. int n = int.Parse(Console.ReadLine());
  2.  
  3. double p1 = 0;
  4. double p2 = 0;
  5. double p3 = 0;
  6. double p4 = 0;
  7. double p5 = 0;
  8.  
  9. for (int i = 1; i < n; n++)
  10. {
  11.     int curentNum = int.Parse(Console.ReadLine());
  12.  
  13.     if (n < 200)
  14.     {
  15.         p1 = p1 / curentNum * 100;
  16.     }
  17.     else if (n < 400)
  18.     {
  19.         p2 = p2 /curentNum * 100;
  20.     }
  21.     else if (n < 600)
  22.     {
  23.         p3 = p3 / curentNum * 100;
  24.     }
  25.     else if (n < 800)
  26.     {
  27.         p4 = p4 / curentNum * 100;
  28.     }
  29.     else if (n >= 800)
  30.     {
  31.         p5 = p5 / curentNum *100;
  32.     }
  33.  
  34.     Console.WriteLine($"{p1:f2}%");
  35.     Console.WriteLine($"{p2:f2}%");
  36.     Console.WriteLine($"{p3:f2}%");
  37.     Console.WriteLine($"{p4:f2}%");
  38.     Console.WriteLine($"{p5:f2}%");
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement