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

📄 solar.cpp

📁 C语言实战105例/王为青, 陈圣亮编著 北京-人民邮电出版社 2007 光盘源码及可运行程序 附注项:共汇集了105个实例
💻 CPP
字号:
//SOLAR.CPP--Example from Chapter 3, "An Introduction to C++"

#include <graphics.h>
#include <iostream.h>
#include <string.h>

struct planet {
	char name[10];
	float distance;
	float radius;
	int color;
	int fill_type;
};

planet solar_system[9];
planet *planet_ptr;
int    planet_num;

int main()
{
	strcpy(solar_system[0].name,"Mercury");
	solar_system[0].distance = 0.4;
	solar_system[0].radius = 0.4;
	solar_system[0].color = EGA_YELLOW;
	solar_system[0].fill_type = EMPTY_FILL;

	planet_ptr = solar_system;
	planet_ptr++;             // Point to second planet structure
	 strcpy (planet_ptr->name,"Venus");
	planet_ptr->distance = 0.7;
	planet_ptr->radius = 1.0;
	planet_ptr->color = EGA_BROWN;
	planet_ptr->fill_type = SOLID_FILL;

	planet_ptr = solar_system;         // Reset to first element
	for (planet_num = 0; planet_num < 2; planet_num++, planet_ptr++) 
        {
	   cout << " \nPlanetary statistics: ";
	   cout << " \nName: "<< planet_ptr->name;
	   cout << " \nDistance from Sun in AU: "<< planet_ptr->distance;
	   cout << " \nRadius in Earth radii: "<<  planet_ptr->radius;
	   cout << " \nColor constant value "<< planet_ptr->color;
	   cout << " \nFill pattern constant value "<< planet_ptr->fill_type;
        }

   return 0;
}

⌨️ 快捷键说明

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