8933. Timer

 

A positive integer n is given. Simulate a countdown timer from n to 0 seconds as shown in the example.

 

Input. One positive integer n.

 

Output. Print all integers from n to 0 inclusive with the text “sek” in a column.

 

Sample input

Sample output

2

2 sek

1 sek

0 sek

 

 

SOLUTION

loop

 

Algorithm analysis

Use a for loop. Print all integers from n to 0 in descending order with the text sek in a column.

 

Algorithm realization

Read the input data.

 

scanf("%d", &n);

 

Print the numbers from n to 0 in descending order with the text sekin a column.

 

for (i = n; i >= 0; i--)

  printf("%d sek\n", i);

 

Java realization

 

import java.util.*;

 

class Main

{

  public static void main(String[] args)

  {

    Scanner con = new Scanner(System.in);

    int n = con.nextInt();

    for(int i = n; i >= 0; i--)

      System.out.println(i + " sek");

    con.close();

  }

}

 

Python realization

Read the input data.

 

n = int(input())

 

Print the numbers from n to 0 in descending order with the text sekin a column.

 

for i in range(n, -1, -1):

  print(i, "sek")