VPanev

Untitled

Nov 2nd, 2021
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. int n = int.Parse(Console.ReadLine());
  2. string result = string.Empty;
  3. int sum = 0;
  4.  
  5. for (int i = 1; i <= n; i++)
  6. {
  7. string input = Console.ReadLine();
  8. int number;
  9. bool isNumber = int.TryParse(input, out number);
  10. if (isNumber)
  11. {
  12. int num = Convert.ToInt32(input);
  13. sum += num;
  14. }
  15. else
  16. {
  17. result += input + "-";
  18. }
  19. }
  20. Console.WriteLine(result.TrimEnd('-'));
  21. Console.WriteLine(sum);
Advertisement
Add Comment
Please, Sign In to add comment