• 研究性学习代码


    输入

    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;
        
    }
  • 相关阅读:
    Sybase:游标用法以及嵌套用法
    EasyUI:获取某个dategrid的所有行数据
    EasyUI:所有的图标
    Sybase:SAP IQ学习笔记
    Sybase:SybaseIQ的几个系统过程
    Sybase:解锁
    Python3:文件读写
    Android Studio 1.0.2 设置内存大小
    关于Android的margin(当前视图与周围视图的距离)和padding(当前视图与内部内容的距离)
    《Android Studio开发实战 从零基础到App上线》资源下载和内容勘误
  • 原文地址:https://www.cnblogs.com/Loi-dfkdsmbd/p/8370802.html
Copyright © 2020-2023  润新知