
02.05.2008, 19:11
|
|
Познавший АНТИЧАТ
Регистрация: 21.03.2007
Сообщений: 1,200
С нами:
10074686
Репутация:
1204
|
|
Сейчас накатал, возможны косяки, проверить нет возможности.
PS: на плюсы перевести думаю справишься..
Код:
#include <stdio.h>
#include <math.h>
void main(void)
{
unsigned int x_point[100], y_point[100];
int lenght = 0, amount = 0;
for (int i = 0; i < 100; i++)
{
printf("point %d: enter xi\n", i + 1);
scanf("%d", &x_point[i]);
printf("point %d: enter yi\n", i + 1);
scanf("%d", &y_point[i]);
}
for (int i = 0; i < 99; i++)
{
if (x_point[i] > 0 && x_point[i + 1] < 0)
amount++;
if (x_point[i] < 0 && x_point[i + 1] > 0)
amount++;
if (y_point[i] > 0 && y_point[i + 1] < 0)
amount++;
if (x_point[i] < 0 && x_point[i + 1] > 0)
amount++;
lenght += sqrt(abs(x_point[i + 1] - x_point[i]) * abs(x_point[i + 1] - x_point[i]) + abs(y_point[i + 1] - y_point[i]) * abs(y_point[i + 1] - y_point[i]));
}
printf("amount: %d", amount);
printf("lenght: %d", lenght / 100);
return;
}
|
|
|