728x90
๋ฐ์ํ
Problem
Source Code
Swift
import Foundation
let n:Int = Int(readLine()!)!
var start = Array(repeating:" ", count: n)
func staircase(n: Int) {
for i in 1...n {
start[n-i] = "#"
print(start.joined())
}
}
staircase(n: n)
JS
'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', function(inputStdin) {
inputString += inputStdin;
});
process.stdin.on('end', function() {
inputString = inputString.split('\n');
main();
});
function readLine() {
return inputString[currentLine++];
}
function staircase(n) {
let start = " ".repeat(n).split('')
for (let i = 1; i <= n; i++) {
start[n-i] = "#"
console.log(start.join(''))
}
}
function main() {
const n = parseInt(readLine().trim(), 10);
staircase(n);
}
728x90
๋ฐ์ํ
'๐ Problem Solution > Etc' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Swift] HackerRank Plus Minus (0) | 2022.02.02 |
---|---|
[Swift] HackerRank Diagonal Difference (0) | 2022.02.01 |
[Swift] HackerRank A Very Big Sum (0) | 2022.01.31 |
[Swift] HackerRank Compare the Triplets (0) | 2022.01.31 |
๋๊ธ