?? 2_6f.cpp
字號:
//2_6f
#include <iostream.h>
#include <iomanip.h>
#include <math.h>
float area(float a, float b, float c); //函數聲明
void main()
{
float a,b,c;
cout <<"please input 3 sides of one triangle:\n";
cin >>a >>b >>c; //輸入時以空格作為數據間隔
float result = area(a,b,c); //函數調用
cout <<setiosflags(ios::fixed) <<setprecision(2)
<<"a=" <<setw(7) <<a
<<",b=" <<setw(7) <<b
<<",c=" <<setw(7) <<c <<endl;
cout <<"area of triangle is " <<setw(10)
<<setprecision(5) <<result <<endl;
}
float area(float a, float b, float c) //函數定義
{
float s=(a+b+c)/2;
return sqrt(s*(s-a)*(s-b)*(s-c));
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -