Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Gerador de CPF válido
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- int main() {
- int i;
- int A,B,C,D,E,F,G,H,I;
- int Dig1,Dig2;
- int aux1,aux2;
- int exit;
- exit=1;
- srand(time(NULL));
- do{
- A=rand() % 10; B=rand() % 10; C=rand() % 10;
- D=rand() % 10; E=rand() % 10; F=rand() % 10;
- G=rand() % 10; H=rand() % 10; I=rand() % 10;
- aux1=(A*10)+(B*9)+(C*8)+(D*7)+(E*6)+(F*5)+(G*4)+(H*3)+(I*2);
- if((aux1%11)<2){
- Dig1=0;
- }
- else {
- Dig1=11-(aux1%11);
- }
- aux2=(A*11)+(B*10)+(C*9)+(D*8)+(E*7)+(F*6)+(G*5)+(H*4)+(I*3)+(Dig1*2);
- if((aux2%11)<2){
- Dig2=0;
- }
- else {
- Dig2=11-(aux2%11);
- }
- printf("\nCPF valido gerado : %d %d %d %d %d %d %d %d %d %d %d \n\n",A,B,C,D,E,F,G,H,I,Dig1,Dig2);
- printf("Deseja gerar outro CPF? \n\n"); printf("(0 to EXIT | 1 to RELOAD)\n\n");
- scanf("%d",&exit);
- } while(exit!=0);
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement