tksgml4924   7년 전

예제에 있는대로 쳐보면 답은 맞는데 틀렸다고나옵니다

wyldecat   7년 전

int 범위를 넘어가는 수에 대해 계산해야될 필요가 있을수도 있어요~


그리고 한꺼번에 출력하는게 아닌, 각 테스트 데이터 마다 출력을 하여도 문제 없답니당.

tksgml4924   7년 전

#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");
} */
}


이렇게 고쳐봤는데도 계속 틀렸다고나오네요

소수점계산이나 몇백억 넘어가는계산 해도 멀쩡한데

wyldecat   7년 전

아니용 그말이 아니구.. int 대신 long long을 써야 될거에요!!

double은..  (17.7-17.6)==0.1이 false인 것처럼 오차가 있어요.

tksgml4924   7년 전

계속 질문드려서 죄송한데 long long으로 바꾸고 풀어도 계속 틀렸다고나오네요 ㅠㅠ

어디가 잘못된건지 모르겠습니다

wyldecat   7년 전

linux g++  환경에선 %I64d가 똑바로 작동 안하는구만요...! %lld 로 입력받으니 AC 뜨네용

댓글을 작성하려면 로그인해야 합니다.