C++の最も速いファイルを読み取る方案のコンピュータの技術を探します

2146 ワード


Add comments7,388 views


    ,      ,                ,         。       C++     cin            ,          cin   。    Pascal read      C/C++ scanf    ,C++       。  C++   Pascal   ?        。                 ,        ,          ,         ,                           ,      。


                       ,         ,          data.txt ,  55MB。                ,    :


View Code CPP
#include 
int main()
{
	int start = clock();
	//DO SOMETHING
	printf("%.3lf
",double(clock()-start)/CLOCKS_PER_SEC); } scanf , : View Code CPP const int MAXN = 10000000; int numbers[MAXN]; void scanf_read() { freopen("data.txt","r",stdin); for (int i=0;i> numbers[i]; } ,cin 6.38 , 。cin , ,cin stdin , , , cout stdout , 。 , cin , ? std::ios::sync_with_stdio(false);, cin stdin 。 : View Code CPP 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> numbers[i]; } ? 2.05 , scanf ! cin cout 。 , , View Code CPP 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