我的C++开头~

/*******************************************************************************
*******************************************************************************/
#include <iostream>
#include <functional>
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <sstream>
#include <utility>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <limits>
#include <memory>
#include <string>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
using namespace std;

#define LOWBIT(x) ( (x) & ( (x) ^ ( (x) - 1 ) ) )
#define CLR(x, k) memset((x), (k), sizeof(x))
#define CPY(t, s) memcpy((t), (s), sizeof(s))
#define SC(t, s) static_cast<t>(s)
#define LEN(s) static_cast<int>( strlen((s)) )
#define SZ(s) static_cast<int>( (s).size() )

typedef double LF;
typedef __int64 LL;		//VC
typedef unsigned __int64 ULL;

typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<double, double> PDD;

typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VF;
typedef vector<string> VS;

template <typename T>
T sqa(const T & x)
{
	return x * x;
}
template <typename T>
T gcd(T a, T b)
{
	if (!a || !b)
	{
		return max(a, b);
	}
	T t;
	while (t = a % b)
	{
		a = b;
		b = t;
	}
	return b;
};

const int INF_INT = 0x3f3f3f3f;
const LL INF_LL = 0x7fffffffffffffffLL;		//15f
const double oo = 10e9;
const double eps = 10e-7;
const double PI = acos(-1.0);

#define  ONLINE_JUDGE

void ace()
{

}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
#endif
	ace();
	return 0;
}
/*******************************************************************************
*******************************************************************************/

### C++ 中以特定字符或关键字开头的实现方式 #### 1. **C++ 的命名约定** 在 C++ 编程中,通常会有一些惯例来定义变量名、函数名以及类名等。这些惯例有助于提高代码的可读性和一致性。例如: - 变量名一般采用小写字母或者下划线分隔的小写单词形式(snake_case)。 - 函数名常使用驼峰命名法(camelCase),即首字母小写,后续单词首字母大写。 - 常量名通常全部大写并用下划线分隔(SCREAMING_SNAKE_CASE)。 如果希望某些标识符以 `C++` 或其他特定字符串开头,则可以通过自定义规则实现这一需求[^1]。 #### 2. **以 C++ 开头的具体应用实例** ##### (1) 定义宏 通过预处理指令可以创建以 `C++` 开始的宏名称: ```cpp #define CPP_VERSION "C++20" #define CPP_AUTHOR_NAME "John Doe" int main() { cout << "Current C++ version is: " << CPP_VERSION << endl; cout << "Author of this program: " << CPP_AUTHOR_NAME << endl; return 0; } ``` 上述例子展示了如何利用宏定义功能设置带有前缀的信息字段[^2]。 ##### (2) 使用结构体成员初始化列表 当构建复杂的数据模型时,可能会遇到需要给多个属性赋初值的情况。此时可以在构造器内部指定参数,并让它们自动关联到对应的实体上: ```cpp struct CPPLibraryInfo { string cppName; int releaseYear; CPPLibraryInfo(string name, int year): cppName(name), releaseYear(year){}; }; int main(){ CPPLibraryInfo info("Boost", 1999); cout<<info.cppName<<" was released in "<<info.releaseYear<<endl; return 0; } ``` 这里我们建立了一个简单的库描述模板,并且它的每一个组成部分均以前述术语作为引导词[^3]。 ##### (3) STL容器操作演示 标准模板库提供了丰富的集合类型供开发者选用,在实际项目里经常能看到如下场景——借助vector存储一系列数值并向其中追加新条目;亦或是运用map记录键值映射关系等等。下面给出一段关于动态调整数组规模的例子: ```cpp #include <iostream> #include <vector> using namespace std; void displayVector(const vector<int>& vec){ for(auto elem : vec){ cout<<elem<<"\t"; } cout<<endl; } int main(){ vector<int> cppNumbers={1,2,3}; // 初始化三个整数 displayVector(cppNumbers); cppNumbers.push_back(4); // 添加第四个元素 displayVector(cppNumbers); cppNumbers.pop_back(); // 移除最后一个元素 displayVector(cppNumbers); return 0; } ``` 此片段着重体现了向量化管理的优势所在,同时也间接反映了其灵活性特点[^4]。 ###
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值