07_02.cpp

来自「一些C++的课件和实验源代码」· C++ 代码 · 共 45 行

CPP
45
字号
// 07_02.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <stdio.h>
#include <conio.h>
#include <list>
using namespace std;

#include <time.h>
#include "timer.h"

#define SIZE 200000

int main(int argc, char* argv[])
{
	char  szCurr[64];	
	int hour, minute, second;
	timer tmCurr;			// 用于显示时间
	timer tmCounter;		// 用于计时

	// 显示系统当前的时间		
	tmCurr.getTimer( szCurr );
	printf( "\n program start at: %s", szCurr );

	// 初始化链表
	list<int> lstValues;
	srand( (unsigned)time( NULL ) );
	for(int i = 0; i < SIZE; i++){
		lstValues.push_back( rand() % SIZE );
	}

	tmCounter.start();	// 开始计时
	lstValues.sort();	// 链表排序
	tmCounter.end();	// 结束计时

	// 显示排序用时
	tmCounter.getTimer(hour, minute, second);
	printf("\n sort spend time: %d hour %d minute %d second",
		hour, minute, second );

	printf("\n press any key to exit...");
	getch();
	return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?