📄 c18b.cpp
字号:
// c18b.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream.h>
#include <time.h>
inline int comp1( int a, int b )
{
int one;
one = a;
one++;
one += a;
one--;
one -= b;
return (one>b)?one:b;
}
int comp2( int a, int b )
{
int one;
one = a;
one++;
one += a;
one--;
one -= b;
return (one>b)?one:b;
}
int main(int argc, char* argv[])
{
double t1, t2;
t1 = (double) clock();
for ( int m = 0; m < 10000; m++ )
for ( int n = 0; n < 10000; n++ )
comp1(m ,n);
t2 = (double)clock();
cout << "调用内联函数运行时间为:\t" << (t2-t1)/CLK_TCK << "秒\n";
t1 = (double)clock();
for ( m = 0; m < 10000; m++ )
for( int n = 0; n < 10000; n++ )
comp2(m, n);
t2 = (double)clock();
cout << "调用外部函数运行时间为:\t" << (t2-t1)/CLK_TCK << "秒\n";
t1 = (double)clock();
for ( m = 0; m < 10000; m++ )
for( int n = 0; n < 10000; n++ )
{
int one;
one = m;
one++;
one += m;
one--;
one -= n;
(one>n)?one:n;
}
t2 = (double)clock();
cout << "直接运行时间为:\t" << (t2-t1)/CLK_TCK << "秒\n";
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -