Cooler_

my ioccc cpf validator xD

Apr 26th, 2012
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.83 KB | None | 0 0
  1. /*
  2. validador de CPF by Cooler_
  3. c00f3r[at]gmail[dot]com
  4. só para deixar o professor de programação nervoso xD
  5. */
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8.  
  9. int
  10. main()
  11. {
  12.  char *cpf=(char *)malloc(sizeof(char)*13);
  13.  int *carry=(int *)malloc(sizeof(int)*13);
  14.  register int x=0,input=0,beta=0,gamma=0,lambda=0,num=0,add=0;
  15.  
  16.  puts("Qual cpf zeh maneh? ")&scanf(" %12s",cpf);
  17.  LOOP1: *(carry+x)=*(cpf+x)-48,x++; if(x^11) goto LOOP1; x=0;
  18.  LOOP2: add+=*(carry+x) *(10-x),x++; if(x^9) goto LOOP2;
  19.  beta=add%11,input=( (!beta) || (!(beta^1)) )?0:11-beta,add=0,x=0;
  20.  LOOP3: add+=*(carry+x)*(11-x),x++; if(x^10) goto LOOP3;
  21.  num=(add/11)*11,gamma=add-num,lambda=( (!gamma) || (!(gamma^1)) )?0:11-gamma;
  22.  fprintf(stdout,"CPF %s\x0a",(!(input^(*(carry+9))) ) && (!(lambda^(*(carry+10))))?"OK":"FAIL");
  23.  free(carry),free(cpf);
  24.  return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment