1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 #include <math.h> 5 6 int main() 7 { 8 int n; 9 scanf("%d", &n); 10 char id[n][19]; 11 int num[17] = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2}; 12 char num2[11] = {'1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'}; 13 int i = 0, j = 0; 14 int count = 0; 15 for (i = 0; i < n; i++) 16 { 17 scanf("%s", id[i]); 18 } 19 int sum = 0; 20 int flag = 1; 21 int flag2 = 1; 22 for (i = 0; i < n; i++) 23 { 24 flag = 1; 25 sum = 0; 26 for (j = 0; j < 17; j++) 27 { 28 if (id[i][j] >= '0' && id[i][j] <= '9') 29 { 30 sum = sum + (id[i][j] - '0') * num[j]; 31 } 32 else 33 { 34 flag = 0; 35 break; 36 } 37 } 38 if (num2[sum % 11] == id[i][17] && flag == 1) 39 { 40 count++; 41 continue; 42 } 43 if (flag2 == 1) 44 { 45 printf("%s", id[i]); 46 47 } 48 if (flag2 == 0) 49 { 50 printf("\n%s", id[i]); 51 } 52 flag2 = 0; 53 } 54 if (count == n) 55 { 56 printf("All passed"); 57 } 58 return 0; 59 }
标签:10,1031,pat,17,int,乙级,++,include,id From: https://www.cnblogs.com/Npc-Hb/p/17235170.html