⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usedefin.cpp

📁 C++的常用算法
💻 CPP
字号:
//这个程序在本书所带软盘中,文件名为USEDEFIN.CPP
//程序利用定义指令对重要的和重复使用的常量进行定义和命名,
//以便在程序中调用。

#include <iostream.h>
#include <conio.h>

#define	pi 3.141596
#define beep '\a'
#define prompt "按下任何一个字母键然后回车..."
#define thanks "谢谢你使用这个程序!"

float radius, circle_length, circle_area, circle_volume;
char wait;

void main( )
{
	clrscr( );   //clear screen

	// 请求输入
	cout << "请输入圆的半径:";
	cin >> radius;
	cout << endl << thanks << endl;

	// 计算圆周长
	circle_length = 2*pi*radius;
	//计算圆面积
	circle_area = pi*radius*radius;
	// 计算球体积
	circle_volume = 4/3*pi*radius*radius*radius;

	// 输出这些计算值
	cout << "圆的周长是:" << circle_length << endl;
	cout << beep << endl;
  	cout << prompt;
  	cin >> wait;
  	cout << "圆的面积是:" << circle_area << endl;
  	cout << beep << endl;
	cout << prompt;
	cin >> wait;
	cout << "球的体积是:" << circle_volume << endl;
	cout << beep << endl;

	cout << thanks << endl;
}

⌨️ 快捷键说明

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