C++(程序设计)第一阶段学习

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;
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值