Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- validador de CPF by Cooler_
- c00f3r[at]gmail[dot]com
- só para deixar o professor de programação nervoso xD
- */
- #include <stdio.h>
- #include <stdlib.h>
- int
- main()
- {
- char *cpf=(char *)malloc(sizeof(char)*13);
- int *carry=(int *)malloc(sizeof(int)*13);
- register int x=0,input=0,beta=0,gamma=0,lambda=0,num=0,add=0;
- puts("Qual cpf zeh maneh? ")&scanf(" %12s",cpf);
- LOOP1: *(carry+x)=*(cpf+x)-48,x++; if(x^11) goto LOOP1; x=0;
- LOOP2: add+=*(carry+x) *(10-x),x++; if(x^9) goto LOOP2;
- beta=add%11,input=( (!beta) || (!(beta^1)) )?0:11-beta,add=0,x=0;
- LOOP3: add+=*(carry+x)*(11-x),x++; if(x^10) goto LOOP3;
- num=(add/11)*11,gamma=add-num,lambda=( (!gamma) || (!(gamma^1)) )?0:11-gamma;
- fprintf(stdout,"CPF %s\x0a",(!(input^(*(carry+9))) ) && (!(lambda^(*(carry+10))))?"OK":"FAIL");
- free(carry),free(cpf);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment