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;
}
相关推荐
Irissgwe14 分钟前
四、进程控制(进程创建与终止)
linux·c++·进程·系统编程·fork·进程创建·进程终止
代钦塔拉23 分钟前
第一篇:工业级 C++/Qt 项目头文件包含原则:告别循环依赖与编译玄学
开发语言·c++·qt
ZPC82101 小时前
规划后的轨迹,如何发给 moveit_servo 执行
c++·人工智能·算法·3d
杜子不疼.1 小时前
【C++ 在线五子棋对战】 - 工具类模块实现
开发语言·c++
橙色阳光五月天2 小时前
Qt C++项目的dump文件分析
开发语言·c++·qt
SoveTingღ2 小时前
【问题解析】Socket已经关闭了,但是端口还处于listening状态?
linux·服务器·c++·qt·socket
计算机安禾2 小时前
【c++面向对象编程】第9篇:友元(friend):破坏封装的“特权”——真的有害吗?
java·c++·log4j
William_wL_3 小时前
【C++】priority_queue(优先级队列)的使用和实现
c++
代码中介商3 小时前
C++ STL入门:vector与字符串流详解
开发语言·c++
fqbqrr3 小时前
2605C++,C++类的继承1
c++