#include "stdafx.h"
#include <iostream>
#include <time.h>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
	int a(100), b(50), n(100000), temp; 
	clock_t start = clock();
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			if (a > b)
				temp = a;
			else
				temp = b;
		}
	}
	clock_t end = clock();
	cout << "IF Time = " << end - start << endl;
	start = clock();
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			temp = a > b ? a : b;
		}
	}
	end = clock();
	cout << "?: Time = " << end - start << endl;
	return 0;
}



版权声明:本文为zhangyandong16原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/zhangyandong16/article/details/23680351