Advertisement
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;
- class Program
- {
- static void Main()
- {
- var n = Console.ReadLine();
- var split = n.ToCharArray();
- int sum = 0;
- int tint = 0;
- foreach (var ch in split)
- {
- if (Char.IsDigit(ch))
- {
- tint = ch - '0';
- sum += tint;
- if (sum > 9)
- {
- sum = 0;
- }
- }
- }
- n = sum.ToString();
- Console.WriteLine(n);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement