木之夏  
海纳百川,有容乃大;壁立千仞,无欲则刚

C++ 与控制台之间的交互

cin-变量输入

cin 是控制外界的流通过控制台,输入到计算机内部

 

cout-控制台输出

cout 是将控制器的变量输出到控制台上,以显示

 

下面看下关于cin cout 的使用实例

这两个函数需要使用 iostream

所以需要使用 :#include <iostream>

#include <iostream>
using namespace std;

int main()
{
    const float PI (3.14159);
    int radius(0);
    cout << "the initial radius is :" << radius << "\n";
    cout << "PI is :" << PI << '\n';
    cout << "Please enter a different radius :\n";
    cin >> radius;
    cout << "now the num of radius is change to:" << radius <<" \n";
    cout << "Pi is still :"<<PI;
    return 0;
}

  

运行结果:

the initial radius is :0
PI is :3.14159
Please enter a different radius :
45
now the num of radius is change to:45
Pi is still :3.14159

posted on 2021-02-12 21:23  木之夏  阅读(396)  评论(0编辑  收藏  举报