c璇█ " />

扫描二维码下载沐宇APP

沐宇

微信扫码使用沐宇小程序

沐宇

c璇█math搴撳嚱鏁版€庝箞寮曠敤

扬州沐宇科技
2023-11-01 15:14:58
c璇█

瑕佷娇鐢–璇█鐨刴ath搴撳嚱鏁帮紝闇€瑕佸湪浠g爜涓寘鍚ご鏂囦欢<math.h>銆傚彧闇€鍦ㄤ唬鐮佺殑寮€澶存坊鍔犱互涓嬭鍙ワ細

#include <math.h>

杩欐牱灏卞彲浠ヤ娇鐢╩ath搴撲腑鐨勫嚱鏁颁簡銆備緥濡傦紝鍙互浣跨敤sqrt鍑芥暟璁$畻涓€涓暟鐨勫钩鏂规牴锛?/p>

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

int main() {
   double num = 16.0;
   double result = sqrt(num);
   printf("The square root of %f is %f\n", num, result);
   return 0;
}

杈撳嚭缁撴灉涓猴細

The square root of 16.000000 is 4.000000

娉ㄦ剰锛岃浣跨敤math搴撳嚱鏁版椂锛岄渶瑕佸湪缂栬瘧鏃堕摼鎺ユ暟瀛﹀簱銆傚湪鍛戒护琛屼腑浣跨敤浠ヤ笅鍛戒护缂栬瘧浠g爜锛?/p>

gcc your_code.c -lm

鍏朵腑锛寉our_code.c 鏄綘鐨凜浠g爜鏂囦欢鍚嶃€?lm鍙傛暟琛ㄧず閾炬帴鏁板搴撱€?/p>

扫码添加客服微信