计算机百万亿次运算C程序

/******************************************************
文件名称:main.c
程序功能:计算机百万亿次运算C程序(main.c)
代码作者:chinayaosir QQ:44633197
测试工具:C + VC IDE / GCC compiler with windows xp
测试日期:01/03/2010
代码目录:
//1.导入头文件
//2.main主程序
修改历史:

*******************************************************/
//1.导入头文件
#include "stdio.h"
#include "time.h"
#include "runtime.h"
#define N 2000

//2.main主程序
int main(void){
    clock_t begin,end;
    begin=clock();   
    runtime(N);
    end=clock();
    printf("运行时间(毫秒):%d/n",(int)(end - begin));
    return 0;
}


/******************************************************
文件名称:runtime.h
程序功能:计算机百万亿次运算C程序(接口)
代码作者:chinayaosir QQ:44633197
blog网址:http://blog.csdn.net/chinayaosir
测试日期:01/01/2010
代码目录:
//1.runtime(int const times)函数使用说明
//2.runtime(int const times)函数接口定义
修改历史:
*******************************************************/
//1.runtime(int const times)函数使用说明
/*
runtime(int times)使用说明和作者电脑debug版本运行结果:
times与运行次数说明
times=200  表示    16亿次= 200 *  200 *  200 *  200   :运行时间(毫秒):15
times=400  表示   256亿次= 400 *  400 *  400 *  400   :运行时间(毫秒):234 
times=800  表示  4096亿次= 800 *  800 *  800 *  800   :运行时间(毫秒):1531
times=1000 表示   1万亿次=1000 * 1000 * 1000 * 1000   :运行时间(毫秒):2984
times=2000 表示  16万亿次=2000 * 2000 * 2000 * 2000   :运行时间(毫秒):23796
times=4000 表示 256万亿次=2000 * 2000 * 2000 * 2000   :运行时间(毫秒):153234
当N=2000,GUN/gcc版本改为release,优化:Maximize Speed,运行时间(毫秒):7828
当N=10000,vc++6.0版本改为release,优化:Maximize Speed,运行时间(毫秒):203
*/

//2.runtime(int const times)函数接口定义
extern void runtime(int const times);


/******************************************************
文件名称:runtime.c
程序功能:计算机百万亿次运算C程序(实现)
代码作者:chinayaosir QQ:44633197
blog网址:http://blog.csdn.net/chinayaosir
测试日期:01/01/2010
代码目录:
//1.导入头文件
//2.runtime()函数实现
    //2.1局部变量
    //2.2容错处理
    //2.3主循环代码
修改历史:

*******************************************************/
//1.导入头文件
#include "runtime.h"

//2.runtime()函数实现
void runtime(int const times){
    //2.1局部变量
    long i,j,k,n,max,count;
    //2.2容错处理
    if ( (times > 65535) || (times < 1 ))
        max=0;
    else
        max=times;       
    //2.3主循环代码
    count=0;
    for (i=0;i<max;i++)
        for (j=0;j<max;j++)
            for(k=0;k<max;k++)
                for(n=0;k<max;k++)
                    count++;
               
}

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值