neZnam121

Untitled

Jan 16th, 2023
670
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.48 KB | None | 0 0
  1.     int n = int.Parse(Console.ReadLine());
  2.     int k = int.Parse(Console.ReadLine());
  3.    
  4.     int nsum = 0;
  5. if (n > 999 && n <= 9999)
  6. {
  7.     while (n > 0)
  8.     {
  9.         int m = 0;
  10.         m = n % 10;
  11.         nsum += m;
  12.         n /= 10;
  13.     }
  14. }
  15. else
  16. {
  17.     return;
  18. }
  19.     if (k < nsum)
  20.     {
  21.         Console.WriteLine("ДА");
  22.         Console.WriteLine(k + nsum);
  23.     }
  24.     else
  25.     {
  26.         Console.WriteLine("НЕ");
  27.         Console.WriteLine(nsum);
  28.     }
  29.  
  30.  
  31.  
Advertisement
Add Comment
Please, Sign In to add comment