Increasing pairs P73501


Statement
 

pdf   zip

thehtml

Write a program that reads sequences of natural numbers, and that for each one prints the number of pairs of consecutive numbers such that the second number of the pair is greater than the first one.

Input

Input consists of a natural number n, followed by n sequences of strictly positive natural numbers. Each sequence ends with a zero.

Output

For every sequence, print in a line the number of pairs of consecutive numbers such that the second number of the pair is greater than the first one.

Public test cases
  • Input

    3
    1 2 3 4 0
    4 4 3 3 2 2 1 1 0
    6 8 4 4 5 0
    

    Output

    3
    0
    2
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++ Java Python
    User solutions
    C C++ Haskell Java Python