arbboter
/*输入前十七位身份证号,程序可算出第十八位的数字是什么!*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
 int wi[18]={7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2,1};
 char check[12]="10X98765432";
 char ai[18];
 int result=0;
 int i=0;
 
begin:
 printf("请输入身份证前17位:");
 gets(ai);
 if( 17!=strlen(ai)/sizeof(char) )
 {
  printf("Error:please try again!\n");
   system("pause");
   system("cls");
   goto begin;
 }
 for( i=0;i<17;i++ )
 {
  result += (ai[i]-48)*wi[i];
 }
 printf("正确的18位身份证为:%s%c\n",ai,check[result%11]);
 system("pause");
 return 0;
}


分类:

技术点:

相关文章:

  • 2021-12-25
  • 2021-11-27
  • 2021-12-23
  • 2021-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-03
相关资源
相似解决方案