1.运用海伦公式计算三角形面积。
2.华氏温度与摄氏温度的转换。
#include "stdafx.h"
#include "iostream"
using namespace std;
#include "math.h"
double a;
double b;
double c;
double s;
double ss;
void input()
{
cout << "请分别输入三角形三边长度,别忘了用空格分开";
cin >> a >> b >> c;
}
void calc()
{
s = (a + b + c) / 2;
ss = s*(s - a)*(s - b)*(s - c);
}
void output()
{
cout << "三角形面积是"<< sqrt(ss);//用sqrt()将ss开平方
}
int main()
{
input();
calc();
output();
return 0;
}
#include "stdafx.h"
#include "iostream"
using namespace std;
#include "math.h"
double c;
double f;
double cc;
double ff;
double d;
void inputc()
{
cout << "请输入摄氏温度:";
cin >> c;
ff = c*1.8 + 32;
cout << "华氏温度为:" << ff << endl;
}
void inputf()
{
cout << "请输入华氏温度";
cin >> f;
cc = (f - 32) / 1.8;
cout << "摄氏温度为" << cc << endl;
}
int main()
{
cout << "请问您已知摄氏温度(0)或华氏温度(1)?,请输入您要查询的代码(0/1)";
cin >> d;
if (d=1)
{
inputc();
}
else
{
inputf();
}
return 0;
}