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;
}
相关推荐
白总Server41 分钟前
GaussDB 分布式数据库调优(架构到全链路优化)
java·网络·c++·架构·go·scala·数据库架构
whoarethenext1 小时前
C++/OpenCV地砖识别系统结合 Libevent 实现网络化 AI 接入
c++·人工智能·opencv
Antonio9151 小时前
【Linux】Linux基础I/O
linux·c++
虾球xz1 小时前
CppCon 2015 学习:C++ devirtualization in clang
开发语言·c++·学习
呆呆的小鳄鱼2 小时前
IO之详解cin(c++IO关键理解)
linux·c语言·c++
看到我,请让我去学习2 小时前
C++核心编程(动态类型转换,STL,Lanmda)
c语言·开发语言·c++·stl
羚羊角uou2 小时前
【C++】模拟实现map和set
java·前端·c++
泽02022 小时前
C++之模板进阶
开发语言·c++·算法
byte轻骑兵5 小时前
【C++特殊工具与技术】优化内存分配(五):显式析构函数的调用
开发语言·c++
谷雨不太卷5 小时前
AVL树的实现
数据结构·c++·算法