###質問です
入力した数字のacosを求めるプログラムを作っています.
実行したところ,数字を入力する部分が3つでてきます.
最初の2つの部分が実行に反映されるようですが,3つ目の部分の消し方がわかりません.
教えてください.
###ソースコード
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
double to_deg(double);
double pi();
int main(void) {
double a=0, b=0; double d; //a = 1.5; //b = 3.0; scanf_s("%lf\n", &a); scanf_s("%lf\n", &b); d = (double)a / (double)b; double d_rad, d_deg; printf("%.5f\n", d); // 逆余弦を取得 d_rad = acos(d); // 弧度法→度数法に変換 d_deg = to_deg(d_rad); // 結果表示 printf("acos(%.8f): %.2f°\n", d, d_deg); while (getchar()); return EXIT_SUCCESS;
}
double to_deg(double r) {
return r * 180.0 / (atan(1.0) * 4.0);
}
###実行結果
1.5
3.0
8
0.50000
acos(0.50000000):60.00°
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。