viraco4a

Simple_Loops_DelenieBezOstatuk

Feb 7th, 2018
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 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 _14_exam2_DivisionWithoutResidue
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int n = int.Parse(Console.ReadLine());
  14. double count1 = 0.0;
  15. double count2 = 0.0;
  16. double count3 = 0.0;
  17.  
  18. for (int i = 0; i < n; i++)
  19. {
  20. int num = int.Parse(Console.ReadLine());
  21. if (num % 2 == 0)
  22. {
  23. count1++;
  24. }
  25. if (num % 3 == 0)
  26. {
  27. count2++;
  28. }
  29. if (num % 4 == 0)
  30. {
  31. count3++;
  32. }
  33. }
  34. double p1 = (count1 / n) * 100.0;
  35. double p2 = (count2 / n) * 100.0;
  36. double p3 = (count3 / n) * 100.0;
  37. Console.WriteLine($"{p1:f2}%");
  38. Console.WriteLine($"{p2:f2}%");
  39. Console.WriteLine($"{p3:f2}%");
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment