Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication23
- {
- class Program
- {
- static int cama (int k)
- {
- int count = 0;
- while (k > 0)
- {
- if (k % 2 == 0)
- count++;
- k /= 10;
- }
- return count;
- }
- static void Main(string[] args)
- {
- int num, evens, n, i, best = 0, bestnum = 0;
- Console.WriteLine("How many numbers you want to enter?");
- n = int.Parse(Console.ReadLine());
- for (i = 1; i <= n; i++)
- {
- Console.WriteLine("Enter a number: ");
- num = int.Parse(Console.ReadLine());
- evens = cama(num);
- if (evens > best)
- {
- best = evens;
- bestnum = num;
- }
- }
- Console.WriteLine("the number with the most even numbers in it is: " + bestnum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement