"SWEA 2019 더블더블"의 두 판 사이의 차이

38번째 줄: 38번째 줄:


==Python==
==Python==
<source lang='python'>
#kcy
#kcy
a = int(input())
a = int(input())

2019년 11월 5일 (화) 10:16 판

1 개요

SWEA 2019 더블더블
  • 2를 반복해서 곱하면서 출력한다.
  • 다른 방법으로는 pow() 함수 사용을 생각해볼 수 있다.
SW Expert 아카데미
# 문제 풀이

틀:SWEA 난이도 1-2

2 C++

#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int t = 1;
    for(int i=0; i<=n ;i++) {
        cout << t << " ";
        t *= 2;
    }
}

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=0; i<=n; i++) {
            System.out.format("%d ", (int)Math.pow(2, i) );  
        }
    }
}

4 Python

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