C語言 計算兩個數的平方和

從鍵盤讀入兩個實數,編程計算並輸出它們的平方和,要求使用數學函數pow(x,y)計算平方值,輸出結果保留2位小數。 程序中所有浮點數的數據類型均爲float。

#include<stdio.h>
#include<math.h>
int main()
{
    float x,y;
    printf("Please input x and y:\n");
    scanf("%f,%f",&x,&y);
    printf("ans=%.2f\n",pow(x,2.0)+pow(y,2.0));
    return 0;
}

小劇場:各自向人潮裏走去。Go to the crowd.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章