说明:含AI辅助生成内容
VSCode 调试 C++。
cpp
//《C++ primer plus》(第六版)中文版
//sqrt.cpp--using the sqrt() function
//程序清单2.4
#include<iostream>
#include<cmath>
int main()
{
using namespace std;
double area;
cout<<"Enter the floor area,in square feet,of your home:";
cin>>area;
double side;
side=sqrt(area);
cout<<"That's the equivalent of a square"<<side<<"feet to the side."<<endl;
cout<<"How fascinating!"<<endl;
return 0;
}
在 VScode 中调试这个 C++ 程序的时候,cin需要在Terminal中输入内容,有时在 Terminal 中无法输入内容。
需要在 VScode 中进行设置:
- CTRL+,
- 搜索栏中输入run in terminal
- 勾选 Whether to run code in integrated Terminal 选项
- cin 就可以正常工作

sqrt.cpp 在 VScode 中运行的结果图片:

以上内容仅供参考,如有不对欢迎指正。
参考书目:《C++ Primer Plus》(第6版)中文版 【美】史蒂芬.普拉达(Stephen Prata)著 张海龙 袁国忠 译 中国工信出版社集团 人民邮电出版社