fork download
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #define _CRT_SECURE_NO_WARNINGS
  4. #pragma warning( disable : 4996 )
  5. int check(char, int *);
  6.  
  7. void main()
  8. {
  9. char id[11];
  10. id[10] = '\0';
  11. int x[2], Y = 0;
  12. int *p = x;
  13.  
  14. printf("請輸入身分證:");
  15. scanf("%s", id);
  16. check(id[0], p);
  17. Y = x[0] + 9 * x[1] + 8*(id[1] - '0') + 7*(id[2] - '0') + 6*(id[3] - '0') + 5*(id[4] - '0') + 4*(id[5] - '0') + 3*(id[6] - '0') + 2*(id[7] - '0') + 1*(id[8] - '0')+(id[9] - '0');
  18.  
  19. if (Y % 10 == 0)
  20. {
  21. printf("此身分證為正確身分證\n");
  22. }
  23. else
  24. {
  25. printf("此身分證為錯誤身分證\n");
  26. }
  27.  
  28. system("pause");
  29. return 0;
  30. }
  31.  
  32. int check(char id_0, int *x)
  33. {
  34. switch (id_0)
  35. {
  36. case 'A': x[0] = 1; x[1] = 0; break; case 'P': x[0] = 2; x[1] = 3; break;
  37. case 'B': x[0] = 1; x[1] = 1; break; case 'Q': x[0] = 2; x[1] = 4; break;
  38. case 'C': x[0] = 1; x[1] = 2; break; case 'R': x[0] = 2; x[1] = 5; break;
  39. case 'D': x[0] = 1; x[1] = 3; break; case 'S': x[0] = 2; x[1] = 6; break;
  40. case 'E': x[0] = 1; x[1] = 4; break; case 'T': x[0] = 2; x[1] = 7; break;
  41. case 'F': x[0] = 1; x[1] = 5; break; case 'U': x[0] = 2; x[1] = 8; break;
  42. case 'G': x[0] = 1; x[1] = 6; break; case 'V': x[0] = 2; x[1] = 9; break;
  43. case 'H': x[0] = 1; x[1] = 7; break; case 'W': x[0] = 3; x[1] = 2; break;
  44. case 'I': x[0] = 3; x[1] = 4; break; case 'X': x[0] = 3; x[1] = 0; break;
  45. case 'J': x[0] = 1; x[1] = 8; break; case 'Y': x[0] = 3; x[1] = 1; break;
  46. case 'K': x[0] = 1; x[1] = 9; break; case 'Z': x[0] = 3; x[1] = 3; break;
  47. case 'L': x[0] = 2; x[1] = 0; break;
  48. case 'M': x[0] = 2; x[1] = 1; break;
  49. case 'N': x[0] = 2; x[1] = 2; break;
  50. case 'O': x[0] = 3; x[1] = 5; break;
  51. default:
  52. printf("第一字必須為大寫英文!");
  53. break;
  54. }
  55. }
Success #stdin #stdout #stderr 0s 2056KB
stdin
Standard input is empty
stdout
請輸入身分證:第一字必須為大寫英文!此身分證為錯誤身分證
stderr
sh: 1: pause: not found