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

📄 prog10_01.cpp

📁 c++最经典的入门书籍
💻 CPP
字号:
// Program 10.1 Accessing External Variables prog10_01.cpp
#include <iostream>
#include <string>
#include <iomanip>
using std::cout;
using std::endl;
using std::string;

// Declare external variables
extern float phi;
extern const double pi;
extern const string days[];
extern int count;

int main() {
  cout << std::setprecision(3) << std::fixed;
  cout << endl
       << "To 3 decimal places..." << endl;

  cout << "...a circle with a diameter of phi has an area of " 
       << pi*phi*phi/4
       << endl;

  cout << "...phi squared is "         << phi*phi << endl;
  cout << "...in fact, phi+1 is also " << phi+1   << endl;

  cout << "Value of count is " << count << endl;

  count += 3;
  cout << "Today is " << days[count] << endl;
  return 0;
}

⌨️ 快捷键说明

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