fork download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. public static void Main()
  6. {
  7. try{
  8. Console.WriteLine("Introduce dos números:");
  9.  
  10. int n1 = Convert.ToInt32(Console.ReadLine());
  11. int n2 = Convert.ToInt32(Console.ReadLine());
  12.  
  13. if(n1 > n2){
  14. for(int i=n1;i<=n2;i++)
  15. {
  16. Console.Write(i + " ");
  17. }
  18. }else{
  19. for(int i=n2;i<=n1;i++){
  20. Console.Write(i + " ");
  21. }
  22. }
  23.  
  24. }catch (Exception e){
  25. Console.WriteLine("Error: se esperaba un número");
  26. }
  27.  
  28. }
  29. }
Success #stdin #stdout 0.02s 24628KB
stdin
1
6
stdout
Introduce dos números: