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_1
  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.  
  22. stopwatch.Stop();
  23. Console.WriteLine($"Час виконання: {stopwatch.Elapsed}");
  24. }
  25.  
  26. else
  27. {
  28. string result = "";
  29. for (int i = 1; i <= n; i++)
  30. {
  31. string i1 = i.ToString();
  32. result += i1 + " ";
  33. }
  34. Console.WriteLine(result);
  35.  
  36. stopwatch.Stop();
  37. Console.WriteLine($"Час виконання: {stopwatch.Elapsed}");
  38.  
  39. long memoryUsed = GC.GetTotalMemory(true);
  40. Console.WriteLine($"Спожита пам'ять: {memoryUsed} байт");
  41. }
  42. }
  43. }
  44. }
Success #stdin #stdout 0.08s 31080KB
stdin
5
stdout
1 2 3 4 5 
Час виконання: 00:00:00.0005587
Спожита пам'ять: 93544 байт