정수형 변수 두 개와 실수형 변수 두 개를 정의해 두 변수 간의 합과 차를 구하는 문제다.
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main()
{
int a, b;
float c, d;
scanf("%d%d%f%f", &a, &b, &c, &d);
printf("%d %d\n", a+b, a-b);
printf("%.1f %.1f", c+d, c-d);
return 0;
}
변수들을 선언하고 입력받은 뒤 정수 두개, 실수 두개를 출력해주었다.
실수형은 소수점 첫번째자리까지 출력했다.
'HackerRank > C' 카테고리의 다른 글
[HackerRank] C > Introduction > Functions in C (0) | 2021.08.14 |
---|---|
[HackerRank] C > Conditionals and Loops > For Loop in C (0) | 2021.08.03 |