You are viewing a single comment's thread. Return to all comments →
function printArray<T>(array: T[]): void { for (let i = 0; i < array.length; i++) { console.log(array[i]); } } function main() { let n: number = parseInt(readLine().trim(), 10); const intArray: number[] = new Array(n); for (let i = 0; i < n; i++) { intArray[i] = parseInt(readLine().trim(), 10); } n = parseInt(readLine().trim(), 10); const stringArray: string[] = new Array(n); for (let i = 0; i < n; i++) { stringArray[i] = readLine().trim(); } printArray<number>(intArray); printArray<string>(stringArray); }
Seems like cookies are disabled on this browser, please enable them to open this website
Day 21: Generics
You are viewing a single comment's thread. Return to all comments →
TypeScript