#include <stdio.h> #include <stdlib.h> #include <string.h> #define INPUTLEN 27 int main() { char szlaszam[INPUTLEN]; int o, i, digit, sum, cs, cc; int mul[] = {9, 7, 3, 1, 9, 7, 3}; printf("GIRO számlaszám 00000000-00000000-00000000 alakban: "); fgets(szlaszam, INPUTLEN, stdin); for (o = 0; o < 19; o += 9) { sum = 0; for (i = 0; i < 7; i++) { digit = szlaszam[o + i] - '0'; sum += digit * mul[i]; } cs = szlaszam[o + 7] - '0'; cc = 10 - (sum % 10); printf("checksum: stored = %d vs calculated = %d -- %sVALID\n", cs, cc, ((cs == cc) ? "" : "IN")); } return 0; }