zoukankan      html  css  js  c++  java
  • 研究性学习代码

    输入

    scanf

    #include<algorithm> 
    #include<iostream>
    #include<cstring>
    #include<cstdio>
    #include<cmath>
    #include<ctime>
    using namespace std;
    
    int lin[1000050]; 
    
    
    
    int main()
    {
            freopen("1.in","r",stdin);
        clock_t start = clock();
        for(int i = 1;i <= 1000000;i ++)
            scanf("%d",&lin[i]);
        clock_t ends = clock(); 
        cout <<"Running Time : "<<(double)(ends - start)/ CLOCKS_PER_SEC << 's' << endl;
        
    }

    gets

    #include<algorithm> 
    #include<iostream>
    #include<cstring>
    #include<cstdio>
    #include<cmath>
    #include<ctime>
    using namespace std;
    
    char lin[7000000]; 
    
    int main()
    {
        freopen("1.in","r",stdin);
        clock_t start = clock();
        gets(lin);
        clock_t ends = clock(); 
        cout <<"Running Time : "<<(double)(ends - start)/ CLOCKS_PER_SEC << 's' << endl;
        
    }

    getline

    #include<algorithm> 
    #include<iostream>
    #include<cstring>
    #include<cstdio>
    #include<cmath>
    #include<ctime>
    using namespace std;
    
    string lin;
    
    int main()
    {
            freopen("1.in","r",stdin);
        clock_t start = clock();
        getline(cin,lin);
        clock_t ends = clock(); 
        cout <<"Running Time : "<<(double)(ends - start)/ CLOCKS_PER_SEC << 's' << endl;
    }

    cin.getline

    #include<algorithm> 
    #include<iostream>
    #include<cstring>
    #include<cstdio>
    #include<cmath>
    #include<ctime>
    using namespace std;
    
    char lin[7000000]; 
    
    int main()
    {
        freopen("1.in","r",stdin);
        clock_t start = clock();
        cin.getline(lin,6888898);
        clock_t ends = clock(); 
        cout <<"Running Time : "<<(double)(ends - start)/ CLOCKS_PER_SEC << 's' << endl;
    }

    cin

    #include<algorithm> 
    #include<iostream>
    #include<cstring>
    #include<cstdio>
    #include<cmath>
    #include<ctime>
    using namespace std;
    
    int lin[1000050]; 
    
    
    
    int main()
    {
        freopen("1.in","r",stdin);
        clock_t start = clock();
        for(int i = 1;i <= 1000000;i ++)
            cin >> lin[i]; 
        clock_t ends = clock(); 
        cout <<"Running Time : "<<(double)(ends - start)/ CLOCKS_PER_SEC << 's' << endl;
    
        
    }

    getchar

    #include<algorithm> 
    #include<iostream>
    #include<cstring>
    #include<cstdio>
    #include<ctime>
    #include<cmath>
    using namespace std;
    
    int lin[1000050]; 
    
    inline void re(int &x)
    {
        x = 0;
        char a = getchar();bool b = 0;
        while(a < '0' || a > '9')
        {
            if(a == '-')
                b = 1;
            a = getchar();
        }
        while(a >= '0' && a <= '9')
            x = x * 10 + a - '0',a = getchar();
        if(b)
            x *= -1;
    }
    
    int main()
    {
        freopen("1.in","r",stdin);
        clock_t start = clock();
        for(int i = 1;i <= 1000000;i ++)
            re(lin[i]);
        clock_t ends = clock(); 
        cout <<"Running Time : "<<(double)(ends - start)/ CLOCKS_PER_SEC << 's' << endl;
    
        
    }

    输出

    cout(结果转为字符串)

    #include<iostream>
    #include<cstring>
    #include<sstream>
    #include<cstdio>
    #include<ctime>
    using namespace std;
    int main()
    {
            freopen("1.out","w",stdout);
        clock_t start = clock();
        for(int i = 1;i <= 1000000 ;i ++)
        {
            stringstream ss;
            string qwq;
            ss << i;
            ss >> qwq;
            cout << qwq << ' ';
        }
        clock_t ends = clock(); 
        cout <<"Running Time : "<<(double)(ends - start)/ CLOCKS_PER_SEC << 's' << endl;
        
    } 

     cout

    #include<algorithm> 
    #include<iostream>
    #include<cstring>
    #include<cstdio>
    #include<cmath>
    #include<ctime>
    using namespace std;
    
    int lin[10000010]; 
    
    int main()
    {
            freopen("1.out","w",stdout);
        clock_t start = clock();
        for(int i = 1;i <= 1000000;i ++)
            cout << i << ' '; 
        clock_t ends = clock(); 
        cout <<"Running Time : "<<(double)(ends - start)/ CLOCKS_PER_SEC << 's' << endl;
        
    }

    printf(结果转为字符串)

    #include<iostream>
    #include<cstring>
    #include<sstream>
    #include<cstdio>
    #include<ctime>
    using namespace std;
    int main()
    {
            freopen("1.out","w",stdout);
        clock_t start = clock();
        for(int i = 1;i <= 1000000 ;i ++)
        {
            stringstream ss;
            string qwq;
            ss << i;
            ss >> qwq;
            printf("%s ",qwq.c_str());
        }
        clock_t ends = clock(); 
        cout <<"Running Time : "<<(double)(ends - start)/ CLOCKS_PER_SEC << 's' << endl;
        
    } 

    printf

    #include<algorithm> 
    #include<iostream>
    #include<cstring>
    #include<cstdio>
    #include<cmath>
    #include<ctime>
    using namespace std;
    
    int lin[10000010]; 
    
    inline void re(int &x)
    {
        x = 0;
        char a = getchar();bool b = 0;
        while(a < '0' || a > '9')
        {
            if(a == '-')
                b = 1;
            a = getchar();
        }
        while(a >= '0' && a <= '9')
            x = x * 10 + a - '0',a = getchar();
        if(b)
            x *= -1;
    }
    
    int main()
    {
            freopen("1.out","w",stdout);
        clock_t start = clock();
            for(int i = 1;i <= 1000000;i ++)
            printf("%d ",i);
        clock_t ends = clock(); 
        cout <<"Running Time : "<<(double)(ends - start)/ CLOCKS_PER_SEC << 's' << endl;
    
    }

    puts

    #include<iostream>
    #include<cstring>
    #include<sstream>
    #include<cstdio> 
    #include<ctime>
    using namespace std;
    int main()
    {
            freopen("1.out","w",stdout);
        clock_t start = clock();
        for(int i = 1;i <= 1000000 ;i ++)
        {
            char qwq[10];
            sprintf(qwq,"%d",i);
            puts(qwq);
        }
        clock_t ends = clock(); 
        cout <<"Running Time : "<<(double)(ends - start)/ CLOCKS_PER_SEC << 's' << endl;
        
    } 

    putchar

    #include<algorithm> 
    #include<iostream>
    #include<cstring>
    #include<cstdio>
    #include<cmath>
    #include<ctime> 
    using namespace std;
    
    int lin[10000010]; 
    
    inline void write(int x)
    {
        if(x<0)
            putchar('-'),x*=-1;
        if(x/10)
            write(x/10);
        putchar(x%10+'0');
    }
    
    int main()
    {
            freopen("1.out","w",stdout);
        clock_t start = clock();
        for(int i = 1;i <= 1000000;i ++)
            write(i),putchar(' ');
        clock_t ends = clock(); 
        cout <<"Running Time : "<<(double)(ends - start)/ CLOCKS_PER_SEC << 's' << endl;
        
    }
  • 相关阅读:
    斜二进制数
    贝贝的波浪数
    1058: 电文保密
    1065: 贝贝的加密工作
    低危漏洞- X-Frame-Options Header未配置
    1064: 不明飞行物(ufo)
    支付
    1067: 密室寻宝(find)
    c++10进制转换为任意2-16进制数字
    1066: 单词游戏(game)
  • 原文地址:https://www.cnblogs.com/Loi-dfkdsmbd/p/8370802.html
Copyright © 2011-2022 走看看