fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace lab4_1_4
  9. {
  10. internal class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. Stopwatch stopwatch = new Stopwatch();
  15. int n = int.Parse(Console.ReadLine());
  16. stopwatch.Start();
  17.  
  18. if (n < 1)
  19. {
  20. Console.WriteLine("Потрiбно ввести додатнє значення n!");
  21. stopwatch.Stop();
  22. Console.WriteLine($"Час виконання: {stopwatch.Elapsed}");
  23. }
  24.  
  25. else
  26. {
  27. StringBuilder result = new StringBuilder();
  28. for (int i = n; i != 0; i--)
  29. {
  30. string i1 = i.ToString();
  31. result.Insert(0,i1 + " ");
  32. }
  33. Console.WriteLine(result);
  34.  
  35. stopwatch.Stop();
  36. Console.WriteLine($"Час виконання: {stopwatch.Elapsed}");
  37.  
  38. long memoryUsed = GC.GetTotalMemory(true);
  39. Console.WriteLine($"Спожита пам'ять: {memoryUsed} байт");
  40. }
  41. }
  42. }
  43. }
Success #stdin #stdout 0.06s 31004KB
stdin
5
stdout
1 2 3 4 5 
Час виконання: 00:00:00.0004584
Спожита пам'ять: 93944 байт