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

📄 ex4_3.cpp

📁 《C++面对对象程序设计》的所有源代码和部分头文件
💻 CPP
字号:
// ex4_3.cpp
// uses structure to model volume of room
#include <iostream>
using namespace std;
////////////////////////////////////////////////////////////////
struct Distance
   {
   int feet;
   float inches;
   };
////////////////////////////////////////////////////////////////
struct Volume
   {
   Distance length;
   Distance width;
   Distance height;
   };
////////////////////////////////////////////////////////////////
int main()
   {
   float l, w, h;
   Volume room1 = {  { 16, 3.5 }, { 12, 6.25 }, { 8, 1.75 } };

   l = room1.length.feet + room1.length.inches/12.0;
   w = room1.width.feet  + room1.width.inches /12.0;
   h = room1.height.feet + room1.height.inches/12.0;

   cout << "Volume = " << l*w*h << " cubic feet\n";
   return 0;
   }

⌨️ 快捷键说明

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