Marathon 2#8932

Marathon 2 (Editorial)

Use a for loop. Print the numbers from to in ascending order.

Algorithm realization

Read the input data.

scanf("%d %d", &a, &b);

Print the athletes' numbers in ascending order.

for (i = a; i <= b; i++)
  printf("%d ", i);

Java realization

import java.util.*;

class Main 
{
  public static void main(String[] args) 
  {
    Scanner con = new Scanner(System.in);
    int a = con.nextInt();
    int b = con.nextInt();
    for(int i = a; i <= b; i++)
      System.out.print(i + " ");
    con.close();
  }
}

Python realization

Read the input data.

a, b = map(int,input().split())

Print the athletes' numbers in ascending order.

for i in range(a, b + 1):
  print(i, end=" ")