Advertisement
SomeoneX

Homework - 06. Divide Without Remainder

Nov 14th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 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.  
  7. namespace Homework___06.Divide_Without_Remainder
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int countOfNum = int.Parse(Console.ReadLine());
  14.  
  15. double p1 = 0;
  16. double p2 = 0;
  17. double p3 = 0;
  18.  
  19. for (int i = 0; i < countOfNum; i++)
  20. {
  21. int num = int.Parse(Console.ReadLine());
  22.  
  23. if (num % 2 == 0)
  24. {
  25. p1++;
  26. }
  27. if (num % 3 == 0)
  28. {
  29. p2++;
  30. }
  31. if (num % 4 == 0)
  32. {
  33. p3++;
  34. }
  35. }
  36.  
  37. double p1Percent = (p1 / countOfNum) * 100;
  38. double p2Percent = (p2 / countOfNum) * 100;
  39. double p3Percent = (p3 / countOfNum) * 100;
  40.  
  41. Console.WriteLine($"{p1Percent:F2}%");
  42. Console.WriteLine($"{p2Percent:F2}%");
  43. Console.WriteLine($"{p3Percent:F2}%");
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement