망공부/코딩테스트

[프로그래머스] a와 b 출력하기 (c, java)

moonmm 2023. 11. 6. 14:18

 

 

 

Lv0. a와 b출력하기

c언어와 java 버전으로 풀이 올립니당

 

#include <stdio.h>

int main(void) {  //c
    int a;
    int b;
    scanf("%d %d", &a, &b);
    if((a<-100000) || (a>100000)){
        printf(" A is out of range.");
        return -1;
    }
    if ((b< -100000) || (b>100000)){
        printf(" B is out of range.");
        return -1;
    }
    printf("a = %d\n", a);
    printf("b = %d\n", b);
    return 0;
}

solution.c

 

 

 

 

 

 

import java.util.Scanner;

public class Solution {  //java
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        

        System.out.println("a = " + a);
        System.out.println("b = " + b);
    } 
}

solution.java