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