C/C++の宿題を片付けます 66代目
■ このスレッドは過去ログ倉庫に格納されています
0359デフォルトの名無しさん
2006/08/01(火) 08:46:34#include <stdio.h>
#include <complex.h>
int main(){
double a,b,c;
double _Complex root1,root2;
printf("input : ");
scanf("%lf %lf %lf",&a,&b,&c);
if(a==0){
fprintf(stderr,"first argument should not be zero");
exit(1);
}
root1 = (-b+csqrt(b*b-4*a*c))/(2*a);
root2 = (-b-csqrt(b*b-4*a*c))/(2*a);
printf("%g%+gi,%g%+gi\n",creal(root1),cimag(root1),
creal(root2),cimag(root2));
return 0;
}
■ このスレッドは過去ログ倉庫に格納されています