반복문(for문, whlie문) (별 찍기)

uoah·2023년 1월 18일
0

문제 풀이

목록 보기
9/9
post-thumbnail

⭐️ 별 찍기 연습

**********
**********
**********
**********
**********
for(let i = 0; i < 5; i++){
  for(let j = 10; j > i; j*=0){
    console.log('*'.repeat(j));
  }
}
*
**
***
****
*****
for(let i = 0; i < 5; i++){
  let star = "*";
  for (let j = 0; j < i; j++){
    star += "*";
  }
  console.log(star);
}
for(let i = 0; i < 5; i++){
  console.log('*'.repeat(i+1));
}
let i = 0
while(i < 5){
  console.log('*'.repeat(i+1));
  i++;
}
*****
****
***
**
*
for(let i = 5; i > 0; i--){
  console.log('*'.repeat(i));
}
for(let i = 0; i < 5; i++){
  console.log('*'.repeat(5-i));
}
for(let i = 0; i < 5; i++){
  let star = "";
  for(let j = 5; j > i; j--){
    star += '*';
  }
  console.log(star);
}
let i = 0;
while(i < 5){
  console.log('*'.repeat(5-i));
  i++;
}
	*
   **
  ***
 ****
*****
for(let i = 0; i < 5; i++){
  console.log(' '.repeat(5-i) + '*'.repeat(i+1));
}
for(let i = 0; i < 5; i++){
  let star = "";
  for(let j = 5; j > i; j--){
    star += " ";
  }
  for(let k = 0; k <= i; k++){
    star += "*";
  }
  console.log(star);
}
let i = 0;
while(i < 5){
  console.log(' '.repeat(5-i) + '*'.repeat(i+1));
  i++;
}
*****
 ****
  ***
   **
    *
for(let i = 0; i < 5; i++){
  console.log(' '.repeat(i) + '*'.repeat(5-i));
}
for(let i = 0; i < 5; i++){
  let star = '';
  for(let j = 0; j < i; j++){
    star += ' ';
  }
  for(let k = 5; k > i; k--){
    star += '*';
  }
  console.log(star);
}
let i = 0;
while(i < 5){
  console.log(' '.repeat(i) + '*'.repeat(5-i));
  i++
}
	*
   ***
  ***** 
 *******
*********
for(let i = 0; i < 5; i++){
  console.log(' '.repeat(5-i) + '*'.repeat(i*2+1));
}
for(let i = 0; i < 5; i++){
  let star = '';
  for(let j = 5; j > i; j--){
    star += ' ';
  }
  for(let k = 0; k < i*2+1; k++ ){
    star += '*';
  }
  console.log(star);
}
let i = 0;
while(i < 5){
  console.log(' '.repeat(5-i) + '*'.repeat(i*2+1));
  i++
}
*********
 *******
  *****
   ***
	*
for(let i = 0; i < 5; i++){
  console.log(' '.repeat(i) + '*'.repeat(9-i*2));
}
for(let i = 0; i < 5; i++){
  let star = '';
  for(let j = 0; j < i; j++){
    star += ' ';
  }
  for(let k = 9; k > i*2; k--){
    star += '*';
  }
  console.log(star);
}
let i = 0;
while(i < 5){
  console.log(' '.repeat(i) + '*'.repeat(9-i*2));
  i++;
}
	*
   ***
  *****
 *******
*********
 *******
  *****
   *** 
    *
for(let i = 0; i < 5; i++){
  console.log(' '.repeat(5-i) + '*'.repeat(i*2+1));
}
for(let j = 0; j < 5; j++){
  console.log(' '.repeat(j+1) + '*'.repeat(9-j*2))
}
let i = 0;
while(i < 5){
  console.log(' '.repeat(5-i) + '*'.repeat(i*2+1));
  i++;
}

let j = 0;
while(j < 5){
  console.log(' '. repeat(j+1) + '*'.repeat(9-j*2))
  j++;
}

0개의 댓글

관련 채용 정보