Advertisement
EndymionSpr

SumaCyfr4

Oct 18th, 2017
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 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 SumaCyfr
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             /* string str = Console.ReadLine();
  14.             uint a= uint.Parse(str);
  15.             uint b=0;
  16.             A:
  17.             b += a % 10;
  18.             a /= 10;
  19.             if (a > 0) goto A;
  20.             Console.WriteLine(b);
  21.             Console.ReadKey(); */
  22.  
  23.             string str = Console.ReadLine();
  24.             uint a = uint.Parse(str);
  25.             uint b = 0;
  26.             while (true)
  27.             {
  28.                 b += a % 10;
  29.                 a /= 10;
  30.                 if (a <= 0) break;
  31.             }
  32.             Console.WriteLine(b);
  33.             Console.ReadKey();
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement