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 ConsoleApp1
- {
- class Program
- {
- static int Func(int n)
- {
- int k = 0;
- if (n % 2 != 0)
- k++;
- if (n / 10 != 0)
- k += Func(n / 10);
- return k;
- }
- static void Main(string[] args)
- {
- Console.Write("a=");
- int a = int.Parse(Console.ReadLine());
- Console.Write("b=");
- int b = int.Parse(Console.ReadLine());
- int mx = -1;//max
- for (int n = a; n <= b; ++n)
- {
- int m = Func(n);
- if (m > mx)
- mx = m;
- //Console.WriteLine("{0}={1}", n, m);
- }
- for (int i = a; i <= b; ++i)
- {
- int m = Func(i);
- if (m == mx)
- Console.WriteLine("{0}", i);
- }
- Console.ReadKey();
- }
- }
- }
Add Comment
Please, Sign In to add comment