Dragon  
Dragon
日历
<2010年8月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
2930311234
统计
  • 随笔 - 58
  • 文章 - 0
  • 评论 - 55
  • 引用 - 0

导航

常用链接

留言簿(3)

随笔分类(58)

随笔档案(58)

搜索

  •  

最新评论

阅读排行榜

评论排行榜

 

 

/*
 *此小程序是连续输入身份证前面的十七位得到最后一位
 
*/

#include
<iostream>
#include
<string>
using namespace std;

int main() 
{
    
string id_17;
    cin
>>id_17;
    
int i=0;
    
int a[17]={7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};
    
int b[17];
    
char c[17]={'1','0','X','9','8','7','6','5','4','3','2'};
    
while(id_17[i]!='\0')
    
{
        b[i]
=id_17[i]-48;
        i
++;
    }

    
int result=0;
    
for (int j=0;j<17;j++)
    
{
        result
+=a[j]*b[j];
    }

    cout
<<c[result%11]<<endl;
    
return 0;
}
posted on 2010-12-01 10:32 Dragon 阅读(644) 评论(2)  编辑 收藏 引用 所属分类: 纯娱乐
评论:
  • # re: 从身份证前十七位算出第十八位  Niinor Posted @ 2010-12-01 15:07
    不准...  回复  更多评论   

  • # re: 从身份证前十七位算出第十八位  Dragon Posted @ 2010-12-02 10:02
    @Niinor
    不可能吧。。。  回复  更多评论   


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


 
Copyright © Dragon Powered by: 博客园 模板提供:沪江博客