문제

나는 Linux에서 C를 쓰고, 부모와 자녀를 포크합니다.부모는 SQRT (ArraySize)를 취하고 나머지는 N 아이들에게 동등하게 나뉩니다.

N 자녀들의 나머지 배열을 똑같이 나머지 부분을 똑같이 나눌 수 있습니까? \

사전에 Thnx :)

도움이 되었습니까?

해결책

int arraySize = 100; // You would get a count from the array here
int nChildren = 5; // This would be provided by you as a parameter to this function
int parentSize = sqrt(arraySize);
int remainder = arraySize - parentSize;
int nChildSize = (remainder / nChildren) + 1
.

다른 팁

당신은 정말로 우리에게 충분히 말하지 않아

Decide size of share for each child, also determine what to do with any "remainder"

For each child 
    allocate an array sufficient to hold the required number of value
    populate the array
.

어떤 비트에 붙어 있습니까?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top