arithmetic.cpp
来自「◆◆◆ 《投掷飞镖记分工具》◆◆◆ 操作系统 : Windows Mobil」· C++ 代码 · 共 53 行
CPP
53 行
#include "StdAfx.h"
#include "PublicFunc.h"
//
// 根据位数来制作一个所有位全为“1”的十六进制的数,比如输入 7 位
// 返回 0x7F,8位则返回 0xFF,即根据位数得到最大值
//
DWORD GetHexDataByBitNum(int nBitNum, BOOL bReverse/*=FALSE*/)
{
DWORD dwHex = 0;
for ( int i=0; i<nBitNum; i++ )
{
dwHex |= (1<<i);
}
if ( bReverse ) return (~dwHex);
return dwHex;
}
//
// 利用当前的时间来产生一个唯一的数字,但不能确保一定是唯一的,如果需要绝对唯一的数字请使用 GUID
//
DWORD GenExclusiveDigit ()
{
DWORD dwExclusiveDigit = 0;
DWORD dwCurrentTime = (DWORD)CTime::GetCurrentTime().GetTime();
dwExclusiveDigit = dwCurrentTime << 16;
DWORD dwCurrentTickCount = GetTickCount();
dwExclusiveDigit |= dwCurrentTickCount & 0x0000ffff;
Sleep ( 1 );
return dwExclusiveDigit;
}
//
// 从数组中找最小值
//
int FindMinValue ( CUIntArray &UIntAry )
{
UINT nMinValue = (UINT)(-1);
int nMinValuePos = 0;
int nSize = UIntAry.GetSize();
for ( int i=0; i<nSize; i++ )
{
UINT nValue = UIntAry.GetAt(i);
if ( nValue < nMinValue )
{
nMinValuePos = i;
nMinValue = nValue;
}
}
return nMinValuePos;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?