欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 文旅 > 明星 > C转C++的学习笔记

C转C++的学习笔记

2025/2/25 23:12:10 来源:https://blog.csdn.net/lfm147258369/article/details/144175795  浏览:    关键词:C转C++的学习笔记

useing namesapce

#include <iostream>//输入输出流//在前面加c
using namespace std;//std为名称空间
//避免函数重复

cin 和 cout

#include <iostream>//输入输出流//在前面加c
using namespace std;//std为名称空间
//避免函数重复int main()
{int n = 0;cin >> n;//输入什么,等价于 scanf("%d", &n);cout << "hello guet!" << ++n << endl;//输出,endl就是\n//没有using namespace std;的情况下//std::cin >> n;//输入什么,等价于 scanf("%d", &n);//std::cout << "hello guet!" << ++n << std::endl;//输出,endl就是\n//std::cout << n++ << "\n";return 0;
}//运算速度不如scanf,printf

变量声明

//
//int main()
//{
//	int n = 0;
//	cin >> n;
//	for (int i = 0; i < 10; i++)
//	{
//		cout << n << " ";
//	}
//	cout << endl;
//
//	for (int i = 0; i < 10; i++)
//	{
//		cout << n + 1 << " ";
//	}
//
//
//	return 0;
//}

bool变量

#include <iostream>
using namespace std;//еbool
//int main()
//{
//	bool flag = true;
//	bool flag2 = -1;
//	bool flag3 = 0;
//
//	cout << flag << endl;
//	cout << flag2 << endl;
//	cout << flag3 << endl;
//
//	return 0;
//} 

const定义常量

#include <iostream>
using namespace std;
//宏定义
//int main()
//{
//	const int Max = 150;//看作宏定义
//
//	//Max = 100;不可改变
//
//	cout << Max << endl;
//
//	return 0;
//}

string类

#include <iostream>
#include <string>
using namespace std;字符串拼接
//int main()
//{
//	//string s = "hello";
//	string s = "hello world";
//	string s_sub = s.substr(6, 5);
//	cout << s_sub << endl;
//
//	string s1 = " xixi";
//	string s2 = s + s1;
//
//	//cin >> s;
//	//输入带有空格:
//	getline(cin, s);
//	cout << s << endl;
//	//cout << s2 << endl;
//	cout << s.length() << endl;
//
//	return 0;
//}

结构体

#include <iostream>
using namespace std;//ṹ//struct stu
//{
//	string name;
//	int age;
//};
//
//
//int main()
//{
//	//Cԣ
//	//struct stu s[10];
//
//	//c++
//	stu a[10];
//
//	return 0;
//}

引用&

#include <iostream>
using namespace std;
//void c(int &a)
//{
//	a += 1;
//}
//
//int main()
//{
//	int a = 4;
//
//	c(a);
//
//	cout << a << endl;
//
//	return 0;
//}

vector

set

map(键值对)

stack(栈)

queue(队列)

unordered_map和unordered_set

bitset 位运算

sort函数

cctype头文件

C++11特性

auto声明

基于范围的for循环

to_string

stoi stod

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词