C++ Primer Plus

第一章 初始C++

#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 使用有返回值的函数

#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

#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;
}

第四章 复合类型

一天学一章:20240428

4.1 数组

数组(array)能够存储多个同类型的值

4.2 字符串

字符串是存储在内存的连续字节中的一系列字符

4.3 String 类简介

4.4 结构简介

#include <iostream>

struct inflatabel
{
	char name[20];
	float volume;
	double price;
};
int main()
{
	using namespace std;
	inflatabel guest =
	{
		"glolo",
		1.88,
		29.99
	};
	inflatabel pal =
	{
		"dads",
		3.12,
		32.99
	};

	cout << "expend your guest list wit" << guest.name;
	return 0;
}

4.5 共用体

4.6 枚举

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值