Advertisement
YavorJS

DivisionWithoutRemainder

Jul 5th, 2016
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 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 DivisionWithoutRemainder
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. var n = int.Parse(Console.ReadLine());
  14. double myCount = 0;
  15. int countP1 = 0;
  16. int countP2 = 0;
  17. int countP3 = 0;
  18. double p1 = 0.0;
  19. double p2 = 0.0;
  20. double p3 = 0.0;
  21. for(var i = 0; i <= n - 1; i++)
  22. {
  23. var number=int.Parse(Console.ReadLine());
  24. myCount++;
  25. if (number % 2 == 0)
  26. {
  27. countP1++;
  28. }
  29. if (number % 3 == 0)
  30. {
  31. countP2++;
  32. }
  33. if (number % 4 == 0)
  34. {
  35. countP3++;
  36. }
  37.  
  38. }//end of for
  39. p1 = countP1/myCount*100;
  40. p2 = countP2/myCount*100;
  41. p3 = countP3/myCount*100;
  42. Console.WriteLine("{0:f2}%", p1);
  43. Console.WriteLine("{0:f2}%", p2);
  44. Console.WriteLine("{0:f2}%", p3);
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement