본문 바로가기

코드업 기초 100제

1045 : [기초-산술연산] 정수 2개 입력받아 자동 계산하기

내 답

#include <iostream>

using namespace std;

int main() {
    long long int a,b;
    scanf("%lld %lld",&a,&b);
    printf("%lld\n",a+b);
    printf("%lld\n",a-b);
    printf("%lld\n",a*b);
    printf("%lld\n",a/b);
    printf("%lld\n",a%b);
    printf("%.2lf\n",(float)a/b);
    
    return 0;
}

 

모범답안

#include <stdio.h>
int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    printf("%d\n", a+b);
    printf("%d\n", a-b);
    printf("%d\n", a*b);
    printf("%d\n", a/b);
    printf("%d\n", a%b);
    printf("%.2lf", (double)a/b);
    return 0;
}