"SWEA 1545 거꾸로 출력해 보아요"의 두 판 사이의 차이

 
(사용자 3명의 중간 판 10개는 보이지 않습니다)
1번째 줄: 1번째 줄:
==개요==
==개요==
;SWEA 1545 거꾸로 출력해 보아요
{{SWEA|난이도=1}}
* https://www.swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV2gbY0qAAQBBAS0
* 1씩 빼는 것을 반복하며 출력한다.
 
{{SWEA 헤더}}
{{SWEA 난이도 1-2}}
|}


==C++==
==C++==
<source lang='cpp'>
<syntaxhighlight lang='cpp'>
</source>
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    for(int i=n; i>=0; i--) {
        cout << i << " ";
    }
}
</syntaxhighlight>


==Java==
==Java==
<source lang='java'>
<syntaxhighlight lang='java'>
import java.util.Scanner;
import java.util.Scanner;
class Solution {
class Solution {
19번째 줄: 24번째 줄:
         int n = sc.nextInt();
         int n = sc.nextInt();
         for( int i=n; i>=0; i--) {
         for( int i=n; i>=0; i--) {
              System.out.format("%d ", i);
            System.out.format("%d ", i);
         }
         }
     }
     }
}
}
</source>
</syntaxhighlight>
 
==Python==
<syntaxhighlight lang='python'>
#kcy
k = int(input())
j = k
for i in range(0, k+1):
    print(j-i, end = ' ')
</syntaxhighlight>
<syntaxhighlight lang='python'>
T = int(input())
for i in range(T, -1, -1):
    print( i, end=' ' )
</syntaxhighlight>

2023년 8월 25일 (금) 01:42 기준 최신판

1 개요[ | ]

SWEA 1545 거꾸로 출력해 보아요

2 C++[ | ]

#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    for(int i=n; i>=0; i--) {
        cout << i << " ";
    }
}

3 Java[ | ]

import java.util.Scanner;
class Solution {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for( int i=n; i>=0; i--) {
            System.out.format("%d ", i);
        }
    }
}

4 Python[ | ]

#kcy
k = int(input())
j = k
for i in range(0, k+1):
    print(j-i, end = ' ')
T = int(input())
for i in range(T, -1, -1):
    print( i, end=' ' )
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}