交所交易人帳號編碼原則
一、 7位數字,第7個數字是檢查碼。
二、 例如:期貨商代號 F123456,交易人帳號1234567。
期貨商代號F1N2N3N4N5N6N7,交易人帳號M1M2M3M4M5M6C7
其中,C7 =mod(10 -
mod(N2 +mod(N3*3,10)+mod(N4*7,10)+N7+
M1+mod(M2*3,10)+mod(M3*7,10)+
M4+mod(M5*3,10)+mod(M6*7,10) ,10) ,10
亦即,檢查碼
C7 =10 - (N2 +(N3*3,除以10的餘數)+(N4*7,10)+N7+
M1+(M2*3, 除以10的餘數 )+(M3*7, 除以10的餘數 )+
M4+(M5*3, 除以10的餘數 )+(M6*7, 除以10的餘數 ) , 除以10的餘數 ) , 除以10的餘數
#include
#include
#include
using namespace std;
void usage()
{
cout<<"Usage:CheckNum Company Custno"<
cout<<"Company:example F910000"<
cout<<"Custno :example 081650"<
cout<<"-----End Check Number"<
}
bool bCheckCompany(char* pszCompany )
{
if ( 0 == isalpha(pszCompany[0]))
{
cout<<"The First Word of Company is not alphs"<
return false;
}
for(int i = 1 ; i
{
if(0 == isdigit(pszCompany[i]) )
{
cout<<"The "<<<"(th) word="" of="" company="" is="" not="" digit"< return false;
}
}
return true;
}
bool bCheckCustno(char* pszCustno )
{
for(int i = 0 ; i
{
if(0 == isdigit(pszCustno[i]) )
{
cout<<"The "<<<"(th) word="" of="" custno="" is="" not="" digit"< return false;
}
}
return true;
}
bool bCheckInput ( int argc,char* argv[] )
{
if (false == bCheckCompany(argv[1]))
{
cout<<"Error Company Format =["<<<"]"<
return false;
}
if (false == bCheckCustno(argv[2]))
{
cout<<"Error Custno Format=["<<<"]"<
return false;
}
return true;
}
void vCalcCustno(char* pszCompany,char* pszCustno)
{
int iN[7];
int iM[6];
memset(iN,0x00,sizeof(iN));
memset(iM,0x00,sizeof(iM));
string strN[7];
string strM[6];
for(int i=0;i<7;i++)
{
strN[i].append(pszCompany+i,1);
sscanf( strN[i].c_str(),"%d",&iN[i]);
cout<<"iN["<<<"]=["<<<"]"<
}
for(int i=0;i<6;i++)
{
strM[i].append(pszCustno+i,1);
sscanf( strM[i].c_str(),"%d",&iM[i]);
cout<<"iM["<<<"]=["<<<"]"<
}
int iCheckNum = 0;
iCheckNum = ( 10- (iN[1] +(iN[2]*3%10+(iN[3]*7)%10)+iN[6]+iM[0]+(iM[1]*3%10)+(iM[2]*7%10)+iM[3]+(iM[4]*3%10)+(iM[5]*7%10) )%10
)%10;
cout<<"iCheckNum=["<<<"]"<
}
int main(int argc,char* argv[])
{
cout<<"-----Start Check Number"<
if( argc < 3 )
{
cout<<"Error input Size=["<<<"],argc <2"< usage();
return -1;
}
if (false == bCheckInput(argc,argv) )
{
usage();
return -1;
}
//----------------------
cout<<"Company="<<
cout<<"Custno="<<
//---------------------
vCalcCustno(argv[1],argv[2]);
cout<<"-----End Check Number"<
return 0;
}
全站熱搜
留言列表