#6379: 為啥會掛勒!?自己拿身分證產生機試好像都OK


wtf (wtf)

學校 : 不指定學校
編號 : 23583
來源 : [140.118.175.37]
最後登入時間 :
2012-02-10 22:34:50
a020. 身分證檢驗 | From: [140.118.175.37] | 發表日期 : 2012-02-10 20:14

#include<iostream>
#include <cstdlib>
#include <cmath>
#include<string>
int main()
{
int  a = 0 , b , c , d ,e;
bool qqq ;
std::string s;
while( std::cin>> s )
{
a = 0;
for ( int i = 8 ; i != 0 ; i-- )
{
a = a + ( s[ i ] - 48 ) * ( 9 - i ) ;
e = ((char)s[ i ]);
//std::cout<<((char)e)<<" "<<s[i]<<std::endl;
}
if ( s [ 0 ] >= 74 && s [ 0 ] <= 90 )
{
b = s [ 0 ] - 57 ;
}
if ( s [ 0 ] == 73 )
{
b = 34 ;
}
if ( s [ 0 ] >= 65 && s [ 0 ] <= 72 )
{
b = s [ 0 ] - 55 ;
}
c = b / 10 ;
d = b % 10 ;
a = a + ( s[ 9 ] - 48 ) + c + d * 9 ;
if ( a % 10 == 0 )
{
std::cout<<"real"<<std::endl;
else
{
std::cout<<"fake"<<std::endl;
}
}
return 0 ;
}
 
ZeroJudge Forum