Advertisement
Infiniti_Inter

5.2(d)

Oct 21st, 2019
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.82 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 ConsoleApp1
  8. {
  9.     class Program
  10.     {
  11.         static int Func(int n)
  12.         {
  13.             int k = 0;
  14.             if (n % 2 != 0)
  15.                 k++;
  16.             if (n / 10 != 0)
  17.                 k += Func(n / 10);
  18.             return k;
  19.         }
  20.  
  21.  
  22.         static void Main(string[] args)
  23.         {
  24.             Console.Write("A=");
  25.             int A = int.Parse(Console.ReadLine());
  26.             Console.Write("B=");
  27.             int B = int.Parse(Console.ReadLine());
  28.             for (int n = A + 1;; ++n)
  29.             {
  30.                 int m = Func(n);
  31.                 if (m == B){
  32.                     Console.WriteLine("{0}", n);
  33.                     break;
  34.                 }
  35.  
  36.             }
  37.            
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement