Advertisement
royroy23

Untitled

Jan 28th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 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 ConsoleApplication23
  8. {
  9. class Program
  10. {
  11. static int cama (int k)
  12. {
  13. int count = 0;
  14. while (k > 0)
  15. {
  16. if (k % 2 == 0)
  17. count++;
  18. k /= 10;
  19. }
  20. return count;
  21. }
  22. static void Main(string[] args)
  23. {
  24. int num, evens, n, i, best = 0, bestnum = 0;
  25. Console.WriteLine("How many numbers you want to enter?");
  26. n = int.Parse(Console.ReadLine());
  27. for (i = 1; i <= n; i++)
  28. {
  29. Console.WriteLine("Enter a number: ");
  30. num = int.Parse(Console.ReadLine());
  31. evens = cama(num);
  32. if (evens > best)
  33. {
  34. best = evens;
  35. bestnum = num;
  36. }
  37. }
  38. Console.WriteLine("the number with the most even numbers in it is: " + bestnum);
  39.  
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement