VPanev

Untitled

Oct 26th, 2021
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 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. result=result.Remove(result.Length-1);
  19. }
  20. }
  21. Console.WriteLine(result);
  22. Console.WriteLine(sum);
Advertisement
Add Comment
Please, Sign In to add comment