C++代码练习(一)入门级

C++代码练习(1)
//1. 输入长方形的长和宽,求长方形的周长和面积。
//2. 从键盘输入一个负整数,求出它的绝对值并输出。
//3. 编写一个C++程序,输出以下信息:
//* ************************
//Very Good!
//*************************
//4. 编写一个程序,已知三角形的三条边a、b、c的值为3、4、5,求出它的周长并输出。
//5. 编写一个程序,已知半径和高的值分别为3和5,输出圆柱体的底面积和体积



#include <iostream>
using namespace std;

/*
int main()
{

	system("pause");
	return 0;
}
*/

/*
int main()
{
	int a, b;
	cout << "请输入长方形的长";
	cin >> a;
	cout << "请输入长方形的宽";
	cin >> b;
	cout << "长方形的周长=" << 2 * a + 2 * b << endl;
	cout << "长方形的面积=" <<  a  * b << endl;

	system("pause");
	return 0;
}
*/

/*
int main()
{
	int a;
	cout << "请输入一个负数" << endl;
	while (1)
	{
		cin >> a;
		if (a > 0)
			cout << "输入违法数,请重新输入"<<endl;
		else
			break;
	}

	a = a * -1;
	cout << "这个数的绝对值是\t" << a<<endl;

	system("pause");
	return 0;
}
*/

/*
#include <iomanip>
int main()
{
	cout << "*************************" << endl << setw(18) << "Very    Good!" << endl << "*************************" << endl;
	
	system("pause");
	return 0;
}
*/

/*
int main()
{
	int a, b, c;
	a = 3; b = 4; c = 5;

	cout << "已知三角形的三条边为" << a <<"," << b << "," << c << endl
		<< "那么三角形的周长为" << a + b + c << endl;

	system("pause");
	return 0;
}
*/

/*
int main()
{
	int r, h;
	r = 3; h = 5;
	cout << "圆柱体的底面半径为" << r << "圆柱体的高为" << h << endl;
	cout << "圆柱的底面积为" << 3.14 * r * r << endl;
	cout << "圆柱的底面积为" << 3.14 * r * r * h << endl;
	system("pause");
	return 0;
}
*/
  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值