zoukankan      html  css  js  c++  java
  • C语言一些常用的功能

    1.测试运行时间:

    #include<stdio.h>
    #include<stdlib.h>
    #include<time.h>
    
    int main()
    {
        clock_t start,finish;
        double duration;
        start=clock();
        /**/  //待测试时间的代码 
        finish=clock();
        duration=(double)(finish-start)/CLOCKS_PER_SEC;
        printf("%lf seconds
    ",duration);
        return 0;
    }

    2.生成随机数:

    #include<stdlib.h>
    #include<stdio.h>
    #include<time.h>
    
    int main()
    {
        srand(unsigned(time(NULL)));
        for(int i=0;i<100;i++)
            printf("%d ",rand()%10);
        return 0;
    }
  • 相关阅读:
    用python将博客园的文章爬取到本地
    2016.7.9
    2016.7.8
    2016.7.7
    2016.7.5
    2016.7.4
    2016.7.3
    2016.7.2
    2016.6.28
    2016.6.27
  • 原文地址:https://www.cnblogs.com/itlqs/p/6553621.html
Copyright © 2011-2022 走看看