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

📄 prog5_07.cpp

📁 一本语言类编程书籍
💻 CPP
字号:
// Program 5.7 Demonstrating the comma operator
#include <iostream>
#include <iomanip>
using std::cout;
using std::cin;
using std::endl;
using std::setw;

int main() {
  int count = 0;
  cout << endl << "What upper limit would you like? ";
  cin >> count;

  cout << endl
       << "integer"                    // Output column headings
       << "     sum"
       << "       factorial"
       << endl;

  for(long n = 1, sum = 0, factorial = 1 ;
                     sum += n, factorial *= n, n <= count ; n++)
    cout << setw(4) << n   << "    "
         << setw(7) << sum << " "
         << setw(15) << factorial
         << endl;
  return 0;
}

⌨️ 快捷键说明

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