#include "stdafx.h"
#include "iostream"
#include "windows.h"
#include "stdlib.h"
using namespace std;
//
//该函数验证输入的SN是否合法
//返回 TRUE:合法
int __fastcall CheckSN(char *sn)
{
long t;
t = atoi(sn);
__asm
{
mov edx,t
and edx,0x80000007
jns err
dec edx
or edx,0xfffffff8
inc edx
jnz err
}
return TRUE;
err:
return FALSE;
}
//
//Main
int _tmain(int argc, _TCHAR* argv[])
{
char sn[11]={0};
long h = -9, l = 0;
cout<<"If the lenght of your name greater then 5 and less then 64,please make it by youself."<<endl;
cout<<"Otherwise please use 'a' in head of the string."<<endl;
//穷举法,似乎效率不高
cout<<"The possible serial number:\n";
//生成假SN
while(TRUE)
{
l ++;
if (l == 0x7FFFFFFF)
{
cout<<sn<<endl;
system("pause");
h ++;
l = 0;
if (h == 0x100)
break;
}
wsprintf(sn,"%02d%08ld",h,l);
if (CheckSN(sn))
{
cout<<sn<<endl;
system("pause");
}
}
#include "stdafx.h" #include "iostream" #include "windows.h" #include "stdlib.h" using namespace std; // //该函数验证输入的SN是否合法 //返回 TRUE:合法 int __fastcall CheckSN(char *sn) { long t; t = atoi(sn); __asm { mov edx,t and edx,0x80000007 jns err dec edx or edx,0xfffffff8 inc edx jnz err }
return TRUE; err: return FALSE; } // //Main int _tmain(int argc, _TCHAR* argv[]) { char sn[11]={0}; long h = -9, l = 0;
cout<<"If the lenght of your name greater then 5 and less then 64,please make it by youself."<<endl; cout<<"Otherwise please use 'a' in head of the string."<<endl; //穷举法,似乎效率不高 cout<<"The possible serial number:\n"; //生成假SN while(TRUE) { l ++; if (l == 0x7FFFFFFF) { cout<<sn<<endl; system("pause"); h ++; l = 0; if (h == 0x100) break; } wsprintf(sn,"%02d%08ld",h,l); if (CheckSN(sn)) { cout<<sn<<endl; system("pause"); } }