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

📄 prog2_01.cpp

📁 c++经典理论课程源文件程序.第二部分源程序
💻 CPP
字号:
// Program 2.1 - Calculating with integer constants
#include <iostream>                       // For output to the screen
using std::cout;
using std::endl;

int main() {  
  cout << 10 + 20               << endl;  // Output is  30
  cout << 10 - 5                << endl;  // Output is   5
  cout << 10 - 20               << endl;  // Output is -10

  cout << 10 * 20               << endl;  // Output is 200
  cout << 10/3                  << endl;  // Output is  3
  cout << 10 % 3                << endl;  // Output is  1
  cout << 10 % -3               << endl;  // Output is  1
  cout << -10 % 3               << endl;  // Output is -1
  cout << -10 % -3              << endl;  // Output is -1

  cout << 10 + 20/10 - 5        << endl;  // Output is  7
  cout << (10 + 20)/(10 - 5)    << endl;  // Output is  6
  cout << 10 + 20/(10 - 5)      << endl;  // Output is 14
  cout << (10 + 20)/10 - 5      << endl;  // Output is  -2

  cout << 4*5/3%4 + 7/3         << endl;  // Output is   4
  return 0;                               // End the program
}

⌨️ 快捷键说明

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