問題文

#include <stdio.h>
#include <math.h>

void f(double a, double b, double c) {
    double D, x1, x2;
    D = b*b - 4*a*c;
    if(D >= 0) {
        x1 = (fabs(b) + sqrt(D)) / (2. * a);
        x1 = b < 0 ? x1 : -x1;
        if(D > 0) {
            x2 = c / (a * x1);
            printf("%lf, %lf\n", x1, x2);
        } else {
            printf("%lf\n", x1);
        }
    }
}

int main(void) {
    f(0.0000000045, 10, 1);
    return 0;
}

トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2023-02-23 (木) 23:33:35