欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 文旅 > 美景 > C/C++ 通用代码模板

C/C++ 通用代码模板

2025/4/18 18:23:17 来源:https://blog.csdn.net/weixin_50993868/article/details/147266492  浏览:    关键词:C/C++ 通用代码模板

✅ C 语言代码模板(main.c

适用于基础项目、算法竞赛或刷题:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>// 宏定义区
#define MAX_N 1000
#define INF 0x3f3f3f3f// 函数声明
void solve();int main() {// 快速读写(可选)// freopen("input.txt", "r", stdin);// freopen("output.txt", "w", stdout);solve();return 0;
}void solve() {// 示例:读取两个整数并输出和int a, b;printf("请输入两个整数:");scanf("%d %d", &a, &b);printf("它们的和是:%d\n", a + b);
}

✅ C++ 代码模板(main.cpp

适用于算法题、开发任务或初学者练习:

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <limits>
#include <iomanip>using namespace std;// 宏定义(可选)
#define int long long
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int INF = 1e18;
const int MOD = 1e9 + 7;// 函数声明
void solve();int32_t main() {fastio;solve();return 0;
}void solve() {// 示例:读取两个整数并输出它们的乘积int a, b;cout << "请输入两个整数:" << endl;cin >> a >> b;cout << "它们的乘积是:" << a * b << endl;
}

版权声明:

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

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

热搜词