c01.cpp

来自「此文件可以能帮你求体积」· C++ 代码 · 共 37 行

CPP
37
字号
// c01.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include <iostream.h>
#include <math.h>

#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif

int main(int argc, char* argv[])
{
	// 圆柱体体积
	double radius, height;
	cout << "请输入圆柱体的半径和高:\n";
	cin >> radius >> height;
	double volume = radius * radius * height * M_PI;
	cout << "该圆柱体的体积:" << volume << endl;

	// 球面积
	cout << "\n请输入球半径:\n";
	cin >> radius;
	double areaOfSphere = 4 * radius * radius * M_PI;
	cout << "该球面的面积为:" << areaOfSphere << endl;

	// 长方体体积
	double length, width;
	cout << "\n请输入长方体的长、宽、高:\n";
	cin >> length >> width >> height;
	volume = length * width * height;
	cout << "该长方体的体积为:" << volume << endl;

	return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?