Linux에서이 프로그램을 실행할 때 부동 소수점 예외가 발생합니다.부동 소수점 예외 이유 (Linux)
#include<stdio.h>
#include<math.h>
int main()
{
int num, num1, num2, n, i, j = 0, t, count = 0;
int root;
printf("Enter number of test cases\n");
scanf("%d", &t);
while (j < t)
{
scanf("%d", &num);
root = (int)sqrt(num);
for (i = 1; i < root; i++)
{
printf("Inside for");
if (num % i == 0)
num1 = i;
while (num1 > 0)
{
n = num1 % 10;
num1 = num1/10;
if (n == 3 || n == 5 || n == 6)
count++;
}
if (num % num1 == 0)
{
num2 = (int)num/num1;
while (num2 > 0)
{
n = num2 % 10;
num2 = num2/10;
if (n == 3 || n == 5 || n == 6)
count++;
}
}
}
j++;
count = 0;
printf("%d", count);
}
return 0;
}
는 사람이 어떻게 수정을 가르쳐 주시겠습니까 그것을
코드를 들여 쓰고 싶을 수도 있습니다. 그러면 코드를 훨씬 더 쉽게 읽을 수 있습니다. –
코드를 들여 쓰거나 프로그램이 충돌하는 줄을 알 수 있다면 도움이 될 것입니다. – Tarik
부동 소수점을 사용하는 유일한 장소는'sqrt' 호출입니다. 예외가 발생하면'num'의 값은 무엇입니까? –