Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace test
- {
- class Program
- {
- static bool isAnswer (int a, int k)
- {
- int j;
- int count = 0;
- for (int i = a; i > 0; i/=10) {
- j = i % 10;
- if (j % 2 == 0)
- count += 1;
- }
- if (count == k)
- return true;
- else
- return false;
- }
- static void Main ()
- {
- Console.WriteLine ("Enter a & b ");
- int a = int.Parse (Console.ReadLine ());
- int b = int.Parse (Console.ReadLine ());
- Console.WriteLine ("Enter K ");
- int k = int.Parse (Console.ReadLine ());
- for (int i = a; i <= b; i++) {
- if (isAnswer (i, k) == true)
- Console.WriteLine ("{0} ", i);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment