int 범위를 넘어가는 수에 대해 계산해야될 필요가 있을수도 있어요~
그리고 한꺼번에 출력하는게 아닌, 각 테스트 데이터 마다 출력을 하여도 문제 없답니당.
13420번 - 사칙연산
#include <stdio.h>
int main() {
int n,i;
char c1,c2;
scanf("%d", &n);
double arr[n];
double n1,n2,n3;
for(i = 0;i < n;i++) {
scanf("%lf %c %lf %c %lf",&n1,&c1,&n2,&c2,&n3);
if(c1 == '+')
if(n1 + n2 == n3) printf("correct\n"); else printf("wrong answer\n");
if(c1 == '*')
if(n1 * n2 == n3) printf("correct\n"); else printf("wrong answer\n");
if(c1 == '/')
if(n1 / n2 == n3) printf("correct\n"); else printf("wrong answer\n");
if(c1 == '-')
if(n1 - n2 == n3) printf("correct\n"); else printf("wrong answer\n");
}/*
for(i = 0;i < n;i++) {
if(arr[i] == 1) {
printf("wrong answer");
} else {
printf("\ncorrect");
}
if(i != n-1) printf("\n");
} */
}
이렇게 고쳐봤는데도 계속 틀렸다고나오네요
소수점계산이나 몇백억 넘어가는계산 해도 멀쩡한데
계속 질문드려서 죄송한데 long long으로 바꾸고 풀어도 계속 틀렸다고나오네요 ㅠㅠ
어디가 잘못된건지 모르겠습니다
댓글을 작성하려면 로그인해야 합니다.
tksgml4924 7년 전
예제에 있는대로 쳐보면 답은 맞는데 틀렸다고나옵니다