Ошибка при компиляции - C (СИ) (149086)
Формулировка задачи:
Программа вычисляет, попадет ли точка за 1-50 шагов в заданную область-кольцо(два круга из одной точки, первый с радиусом 5, второй с радиусом 10). Не понимаю, что сделал не так. Функции прописаны в ручную, так требовало задание.
#include <stdio.h>
const int NSTEPS = 50;
const int I0 = 1;
const int J0 = -30;
const int L0 = 1;
const int a = 10;
const int b = 10;
const int r1 = 5;
const int r2 = 10;
const int TRUE = 1;
const int FALSE = 0;
int div(x, y) {
int res;
if (x * y >= 0)
res = x / y;
else
res = x / y - 1;
return res;
}
int mod(x, y) {
return x - div(x, y) * y;
}
int max2(x, y) {
int res;
if (x > y)
res = x;
else
res = y;
return res;
}
int min2(x, y) {
int res;
if (x < y)
res = x;
else
res = y;
return res;
}
int min3(x, y, z) {
int res;
if (x < y && x < z)
res = x;
else if (y < z)
res = y;
else
res = z;
return res;
}
int sign(x) {
int res;
if (x > 0)
res = 1;
else if (x < 0)
res = -1;
else
res = 0;
return res;
}
int abs(x) {
int res;
if (x < 0)
res = (-1) * x;
return res;
}
int trfal(I0, J0, a, b) {
int isnside;
if (((I0 - a)*(I0 - a) + (J0 - b)*(J0 - b)) >= 5 || (((I0 - a)*(I0 - a) + (J0 - b)*(J0 - b)) <= 10));
{
isnside = TRUE;
}
else
{
isnside = FALSE;
}
return isnside;
}
int main() {
int i = I0;
int j = J0;
int l = L0;
int it = 0;
int jt = 0;
int lt = 0;
int k = 1;
int isnside = FALSE;
while ((FALSE == (isnside = trfal(i, j, a, b))) && (k <= NSTEPS)) {
it = max2(min2((i + j в€’ l в€’ k), (i в€’ j + l в€’ k)), min2((k + i в€’ j в€’ l), (k в€’ i в€’ j + l)));
jt = j + mod(l*(sign(j)), 20) + mod(k*(sign(i)), 10);
lt = abs(i в€’ j + l в€’ k)*sign(i)*sign(j);
i = it;
j = jt;
l = lt;
++k;
}
if (TRUE == isnside) {
printf("YES\n");
printf("%d %d %d %d\n", i, j, l, k);
}
else {
printf("NO\n");
printf("%d %d %d\n", i, j, l);
}
return 0;
}Решение задачи: «Ошибка при компиляции»
textual
Листинг программы
int x, y, res; res = x/y;
Объяснение кода листинга программы
- Объявляются три переменные типа int: x, y, res.
- Переменной res присваивается значение, равное результату деления x на y.