C++ Primer Plus

第一章 初始C++

cpp 复制代码
#include <iostream> //#:预处理

int main(void) //void:无参数
{
	using namespace std;

	int carrots; //定义声明语句:开辟内存空间, int:整型 

	cout << "how many corrots do you have?" << endl; //cout:输出流(out) endl:回车换行符
	cin >> carrots;
	cout << "here are two more.";
	carrots = carrots + 2;
	cout << "now you have " << carrots << " carrots" << endl;

	return 0; //标识符:程序成功运行
}

第二章 函数

2.1 使用有返回值的函数

cpp 复制代码
#include <iostream>
#include <cmath>

int main()
{
	using namespace std;
	double area;
	cout << "输入面积:" << endl;
	cin >> area;
	double side;
	side = sqrt(area);
	cout << "输出边长:" << side << endl;

	return 0;
}

第三章 处理数据

一天学一章:20240427

cpp 复制代码
#include <iostream>

int main()
{
	using namespace std;

	cout << "\aOperation \"Hyperhype\" is now activated:\n";
	cout << "Enter your agent code:________\b\b\b\b\b\b\b\b";

	long code;
	cin >> code;
	cout << "\ayou entered" << code << "...\n";

	return 0;
}
相关推荐
星夜钢琴手1 小时前
推荐的 Visual Studio 2026 Insider C++ 程序项目属性配置
c++·visual studio
kyle~2 小时前
Qt---setAttribute设置控件或窗口的内部属性
服务器·前端·c++·qt
hsjkdhs2 小时前
C++之多态
开发语言·jvm·c++
kyle~2 小时前
C++STL---静态数组array
开发语言·c++
kk”3 小时前
C++ List
开发语言·c++
HalvmånEver3 小时前
红黑树实现与原理剖析(上篇):核心规则与插入平衡逻辑
数据结构·c++·学习·算法·红黑树
初圣魔门首席弟子4 小时前
c++ bug 记录(merge函数调用时错误地传入了vector对象而非迭代器。)
java·c++·bug
郝学胜-神的一滴4 小时前
Linux下的阻塞与非阻塞模式详解
linux·服务器·开发语言·c++·程序人生·软件工程
泽虞5 小时前
《Qt应用开发》笔记p2
linux·开发语言·数据库·c++·笔记·qt
Samsong7 小时前
《C++ Primer Plus》读书笔记 第二章 开始学习C++
c++·后端