# ios::sync_with_stdio(false);

#include <ctime>
int main()
{
int start = clock();
//DO SOMETHING
printf("%.3lf\n",double(clock()-start)/CLOCKS_PER_SEC);
}﻿﻿﻿﻿﻿﻿

最简单的方法就算写一个循环scanf了，代码如下：

const int MAXN = 10000000;

int numbers[MAXN];

void scanf_read()
{
freopen("data.txt","r",stdin);
for (int i=0;i<MAXN;i++)
scanf("%d",&numbers[i]);
}

?可是效率如何呢？在我的电脑Linux平台上测试结果为2.01秒。接下来是cin，代码如下
const int MAXN = 10000000;

int numbers[MAXN];

void cin_read()
{
freopen("data.txt","r",stdin);
for (int i=0;i<MAXN;i++)
std::cin >> numbers[i];
}

const int MAXN = 10000000;

int numbers[MAXN];

void cin_read_nosync()
{
freopen("data.txt","r",stdin);
std::ios::sync_with_stdio(false);
for (int i=0;i<MAXN;i++)
std::cin >> numbers[i];
}

const int MAXS = 60*1024*1024;
char buf[MAXS];

void analyse(char *buf,int len = MAXS)
{
int i;
numbers[i=0]=0;
for (char *p=buf;*p && p-buf<len;p++)
if (*p == ' ')
numbers[++i]=0;
else
numbers[i] = numbers[i] * 10 + *p - '0';
}

const int MAXN = 10000000;
const int MAXS = 60*1024*1024;

int numbers[MAXN];
char buf[MAXS];

void fread_analyse()
{
freopen("data.txt","rb",stdin);
int len = fread(buf,1,MAXS,stdin);
buf[len] = '\0';
analyse(buf,len);
}

const int MAXN = 10000000;
const int MAXS = 60*1024*1024;

int numbers[MAXN];
char buf[MAXS];

void read_analyse()
{
int fd = open("data.txt",O_RDONLY);
int len = read(fd,buf,MAXS);
buf[len] = '\0';
analyse(buf,len);
}

0.