iostream

  1. cout: 用于标准输出,可以使用<<操作符将数据输出到屏幕上。
1
std::cout << "Hello, world!" << std::endl;
  1. cin: 用于标准输入,可以使用>>操作符从用户输入中读取数据。

    1
    2
    int num;
    std::cin >> num;
    

  2. endl: 输出换行符并刷新输出缓冲区。

    1
    std::cout << "Hello" << std::endl;
    

  3. cerr: 用于输出错误信息,通常用于标准错误流。

1
std::cerr << "Error: something went wrong!" << std::endl;
  1. fixedsetprecision: 用于控制浮点数的输出精度。
    1
    2
    double num = 3.14159;
    std::cout << std::fixed << std::setprecision(2) << num << std::endl;