如果需要为某个case分支定义并初始化一个变量,我们应该把变量定义在块内,从而确保后面的所有case标签都在变量的作用域之外。case true: { // 正确,声明语句位于语句块内部 string file_name = get_file_name(...
分类:
编程语言 时间:
2015-03-12 06:17:18
阅读次数:
145
#include
#include
#include
using namespace std;
typedef long long LL;
const int maxn = 10000010;
int mu[maxn], prime[maxn], vis[maxn], sum[maxn];
int cnt;
int a, b;
void mobi(int n)
{
mu[1] = 1;...
分类:
其他好文 时间:
2015-03-11 17:29:53
阅读次数:
113
#include
#include
#include
using namespace std;
typedef long long LL;
const int maxn = 100010;
int mu[maxn], prime[maxn], vis[maxn];
int cnt;
int a, b, c, d, k;
void mobi(int n)
{
mu[1] = 1;
for(...
分类:
其他好文 时间:
2015-03-11 17:29:36
阅读次数:
147
1 #include 2 #include 3 #include 4 #define M 21 5 #define sc(x) scanf("%d",&x) 6 #define pf(x) printf("%d\n",x) 7 #define PF(x) printf("%d ",x) 8 #de....
分类:
其他好文 时间:
2015-03-11 16:22:04
阅读次数:
222
C++程序会用到的一项预处理功能是头文件保护符,头文件保护符依赖于预处理变量。预处理变量有两种状态:已定义和未定义,#define指令把一个名字设定为预处理变量,另外两个指令则分别检查某个指定的预处理变量是否已经定义:#ifdef当且仅当变量已定义的时候为真,#inndef当且仅当变量未定义时为.....
分类:
编程语言 时间:
2015-03-11 01:56:02
阅读次数:
132
decltype作用是选择并返回操作数的数据类型。 decltype(f()) sum = x; // sum的类型就是函数f的返回类型 如果decltype使用的表达式是一个变量,则decltype返回该变量的类型(包括顶层const和const在内):const int ci=0, &...
分类:
编程语言 时间:
2015-03-11 00:43:27
阅读次数:
189
DescriptionThe ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all have to change the four-digit room numbers on their offices.
— It is a m...
分类:
其他好文 时间:
2015-03-10 19:29:50
阅读次数:
227
初次接触回溯法,觉得真是很好用,可以减少很多不必要的枚举。
cur变量表示进行到的当前第cur+1个数。 作为A【】的下标出现。
#include
using namespace std;
int n,vis[20],isp[100],A[30],maxn=0;
void dfs(int cur) {
if(cur==n&&isp[A[0]+A[n-1]]){
for(...
分类:
其他好文 时间:
2015-03-10 17:24:11
阅读次数:
139
bool is_prime (const vector& primes, int num){ for (const auto& prime : primes) { if (num % prime == 0) { return false; } ...
分类:
其他好文 时间:
2015-03-10 13:26:31
阅读次数:
103
#include#include int main () { printf("n e\n"); printf("- -----------\n"); printf("0 1\n"); printf("1 1\n"); printf("2 2.5\n"); double t=0.5,sum=2....
分类:
其他好文 时间:
2015-03-10 10:11:14
阅读次数:
111