FUNCTOVR.C
资源名称:C.rar [点击查看]
上传用户:qq5388545
上传日期:2022-07-04
资源大小:29849k
文件大小:1k
源码类别:
界面编程
开发平台:
C/C++
- #include <stdio.h>
- #include <time.h>
- float add_em(long int a, float b)
- {
- float result;
- result = a + b;
- return(result);
- }
- void main(void)
- {
- long int i;
- float result = 0;
- time_t start_time, stop_time;
- printf("Working...n");
- time(&start_time);
- for (i = 1; i <= 100000L; i++)
- result += i;
- time(&stop_time);
- printf("Using loop %d secondsn", stop_time - start_time);
- printf("Working...n");
- time(&start_time);
- for (i = 1; i <= 100000L; i++)
- result = add_em(i, result);
- time(&stop_time);
- printf("Using function %d secondsn", stop_time - start_time);
- }