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 天前
手动实现std:iterator/std:string/std::vector/std::list/std::map/std:set
c++·stl
小羊羊Python1 天前
Sound Maze - 基于 SFML+C++14 的音效迷宫开源游戏 | MIT 协议
c++·游戏·开源
txinyu的博客1 天前
HTTP服务实现用户级窗口限流
开发语言·c++·分布式·网络协议·http
代码村新手1 天前
C++-类和对象(上)
开发语言·c++
txinyu的博客1 天前
map和unordered_map的性能对比
开发语言·数据结构·c++·算法·哈希算法·散列表
mjhcsp1 天前
C++ 后缀数组(SA):原理、实现与应用全解析
java·开发语言·c++·后缀数组sa
hui函数1 天前
如何解决 pip install 编译报错 ‘cl.exe’ not found(缺少 VS C++ 工具集)问题
开发语言·c++·pip
码农小韩1 天前
基于Linux的C++学习——循环
linux·c语言·开发语言·c++·算法
消失的旧时光-19431 天前
C++ 命名空间 namespace 讲透:从 std:: 到工程实践
开发语言·c++
程序员Jared1 天前
C++11—thread库
c++·thread