2008年6月9日 星期一

Visual C - 算時間差

#include stdlib.h
#include stdio.h
#include math.h
#include sys/timeb.h

struct _timeb time1, time2; //在gcc中,要去除underline
float time_diff;

main()
{
char ch;
printf("\nPlease enter a character: ");
scanf(" %c",&ch);

_ftime( &time1);

printf("\nPlease enter another character: ");
scanf(" %c",&ch);
_ftime( &time2);

time_diff=time2.time-time1.time+(time2.millitm-time1.millitm)*0.001; // 計算時間差

printf("\nThe time used = %.3f seconds\n", time_diff);

沒有留言:

[c#] process 使用方法

寫法1. Process proc = new Process(); / /PowerShell.exe path proc.StartInfo.FileName = @"c:\Windows\System32\ WindowsPowerShell\v1.0\ powe...