Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int n = int.Parse(Console.ReadLine());
- string result = string.Empty;
- int sum = 0;
- for (int i = 1; i <= n; i++)
- {
- string input = Console.ReadLine();
- int number;
- bool isNumber = int.TryParse(input, out number);
- if (isNumber)
- {
- int num = Convert.ToInt32(input);
- sum += num;
- }
- else
- {
- result += input + "-";
- }
- }
- Console.WriteLine(result.TrimEnd('-'));
- Console.WriteLine(sum);
Advertisement
Add Comment
Please, Sign In to add comment