Advertisement
rabbit_nando

Gerador de CPF simples

Jul 17th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.17 KB | None | 0 0
  1. /*
  2. rabbit_nando
  3. V.1.1
  4. Gerador de cpf
  5. Linguagem: C++
  6. Script que gera uma sequencia de numeros simulando  numeros de CPF.
  7. */
  8. #include <iostream>
  9. #include <cstdlib>
  10. #include <ctime>
  11.  
  12. using namespace std;
  13.  
  14. int main()
  15. {
  16.      int num[9],sm1,sm2,i,cpf,quant;
  17.  
  18.      cout << "\n\t###################################\n";
  19.      cout << "\n\t####### -Gerador de cpf V.1- ######\n";
  20.      cout << "\n\t###################################\n";
  21.  
  22. //Gerando os numeros de CPF
  23.      quant = 0;
  24.      while(quant < 1)
  25.      {
  26.           cout << "Digite um numero: ";
  27.           cin >> quant;
  28.  
  29.      for(cpf = 1; cpf <= quant; cpf++)
  30.      {
  31.             srand(time(NULL));
  32.           for(i = 1; i <= 9; i++)
  33.           {
  34.                num[i] = rand()%9; // gerando numeros aleatorios entre 0 e 9
  35.           }
  36.      }
  37.      }
  38. //Primeiro digito
  39.      sm1 = 1;
  40.           sm1 = rand()%9;
  41. //Segundo digito
  42.      sm2 = 1;
  43.           sm2 = rand()%9;
  44.  
  45.  
  46.      //Imprime CPF
  47.      for(i = 1; i <= 9; i++)
  48.      {
  49.           cout << num[i];
  50.           if(i - 1 == 2 ) cout << ".";
  51.           if(i - 1 == 5 ) cout << ".";
  52.      }
  53.      cout << "\nOs dois ultimos digitos " << sm1 << " " << sm2;
  54.      cout << endl;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement