alias3glw

Cedula Ecuador

May 27th, 2015
2,762
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.49 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  4.  
  5. int main(int argc, char** argv) {
  6.    
  7.     int cedula,ced,pares,impares,total,dec=0;
  8.     int a,b,c,d,e,f,g,h,i,j,k;
  9.    
  10.     cout<<"Ingrese su cedula: "<<endl;
  11.     cin>>cedula;
  12.    
  13.     ced=cedula;
  14.    
  15.     a=cedula/1000000000;
  16.     cedula=cedula-(a*1000000000);
  17.     b=cedula/100000000;
  18.     cedula=cedula-(b*100000000);
  19.     c=cedula/10000000;
  20.     cedula=cedula-(c*10000000);
  21.     d=cedula/1000000;
  22.     cedula=cedula-(d*1000000);
  23.     e=cedula/100000;
  24.     cedula=cedula-(e*100000);
  25.     f=cedula/10000;
  26.     cedula=cedula-(f*10000);
  27.     g=cedula/1000;
  28.     cedula=cedula-(g*1000);
  29.     h=cedula/100;
  30.     cedula=cedula-(h*100);
  31.     i=cedula/10;
  32.     cedula=cedula-(i*10);
  33.     j=cedula/1;
  34.     cedula=cedula-(j*1);
  35.    
  36.     //cout<<cedula<<endl<<a<<endl<<b<<endl<<c<<endl<<d<<endl<<e<<endl<<f<<endl<<g<<endl<<h<<endl<<i<<endl<<j<<endl;
  37.     if (cedula>2400000000){
  38.         cout<<"Numero de cedula invalido."<<endl;
  39.     }else{
  40.        
  41.         pares=b+d+f+h;
  42.        
  43.         a=a*2;
  44.         if (a>9){
  45.             a=a%10+a/10;
  46.         }
  47.        
  48.         c=c*2;
  49.         if (c>9){
  50.             c=c%10+c/10;
  51.         }
  52.        
  53.         e=e*2;
  54.         if (e>9){
  55.             e=e%10+e/10;
  56.         }
  57.        
  58.         g=g*2;
  59.         if (g>9){
  60.             g=g%10+g/10;
  61.         }
  62.        
  63.         i=i*2;
  64.         if (i>9){
  65.             i=i%10+i/10;
  66.         }
  67.        
  68.         impares=a+c+e+g+i;
  69.        
  70.         total=pares+impares;
  71.        
  72.        
  73.        
  74.         while (dec-total!=j && dec<total+10){
  75.             dec=dec+10;
  76.         }
  77.        
  78.         if (dec-total==j){
  79.             cout<<"valido"<<endl;
  80.         }else {
  81.             cout<<"Cedula erronea"<<endl;
  82.         }
  83.        
  84.        
  85.        
  86.    
  87.     }
  88.     return 0;
  89.    
  90. }
Advertisement
Add Comment
Please, Sign In to add comment