• + 0 comments

    Typescript

    'use strict';
    
    process.stdin.resume();
    process.stdin.setEncoding('utf-8');
    let inputString: string = '';
    let inputLines: string[] = [];
    let currentLine: number = 0;
    process.stdin.on('data', function(inputStdin: string): void {
        inputString += inputStdin;
    });
    
    process.stdin.on('end', function(): void {
        inputLines = inputString.split('\n');
        inputString = '';
        main();
    });
    
    function readLine(): string {
        return inputLines[currentLine++];
    }
    
    function main() {
        // Enter your code here
        while (readLine()) {
            const previousValue = parseInt(inputLines[currentLine - 1])
            
            const arr = inputLines.slice(currentLine, currentLine + previousValue)
            
            printArray(arr)
    
            currentLine += previousValue
        }
    }
    
    function printArray<T>(arr: Array<T>) {
        arr.forEach(item => console.log(item))
    }