нужна помощь: как на си написать извлечение корня без подключения библиотеки math.h и функции sqrt(), соответственно?
trixter_inactive4548223, функцией... The post was merged to previous Nov 8, 2021 trixter_inactive4548223, #include Void main() ( val=9; if (val == 0 || val == 1) printf(“The square root is %d”, val) ; exit() ; int counter = 1, sqroot=1, output; while (sqroot <= val) ( counter++; sqroot = counter*counter; ) output= counter - 1; printf(“The square root is %d”, output) ; )
int sqrt (int v) { int L = 0, R = v; int M = (L + R) /2; while(R - L > 1){ if(M * M <= v) { L = M; } else { R = M; } M = (L + R)/2; } } C int sqrt (int v) { int L = 0, R = v; int M = (L + R) /2; while(R - L > 1){ if(M * M <= v) { L = M; } else { R = M; } M = (L + R)/2; } } Чуваки бинпоиск юзают, сам не проверял