Marathon 3#8934

Marathon 3 (Editorial)

Use a for loop to print the athletes' numbers. Print the numbers from to in decreasing order.

Algorithm implementation

Read the input data.

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

Print the athletes' numbers in decreasing order.

for (i = b; i >= a; i--)
  printf("%d ", i);

Java implementation

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 = b; i >= a; i--)
      System.out.print(i + " ");
    con.close();
  }
}

Python implementation

Read the input data.

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

Print the athletes' numbers in decreasing order.

for i in range(b, a - 1, -1):
  print(i)