C/C++の宿題を片付けます 96代目
■ このスレッドは過去ログ倉庫に格納されています
0817デフォルトの名無しさん
2007/10/08(月) 04:34:17#include <stdio.h>
#include <math.h>
int main(void)
{
int i;
double c[3], xre[2], xim[2] = {0}, j;
for(i=0; i<3; i++) {
printf("Input c[%d]:", i);
scanf("%lf", c + i);
}
j = c[1] * c[1] - 4 * c[0] * c[2];
if(j>=0) {
xre[0] = (-c[1] - sqrt(j)) / ( 2 * c[0]);
xre[1] = (-c[1] + sqrt(j)) / ( 2 * c[0]);
}
else {
xre[0] = xre[1] = -c[1] / (2 * c[0]);
xim[0] = sqrt(-j) / (2 * c[0]);
xim[1] = -sqrt(-j) / (2 * c[0]);
}
for(i=0; i<2; i++) {
printf("xre[%d] = %f xim[%d] = %f\n", i, xre[i], i, xim[i]);
}
return 0;
}
■ このスレッドは過去ログ倉庫に格納されています