char * itoa(int ivalue) { int leni; char * cval; leni = numdig(ivalue,1) ; if ((cval = (char *) malloc((leni + 1) * sizeof(char))) == (char *) NULL) return (char *) 0; sprintf(cval,"%*d",leni,ivalue); return cval; }
node1 *radix_sort(node1 *rec) { node1 *r, *nex; int poc = 0 ; int i, j, k; int larg = large(rec); int m = numdig(larg); /* These statements create pockets */ for(k = 0 ; k < 10; k++) { pocket[k] = (node1 *)malloc(sizeof(node1)); pocket1[k] = (node1 *)malloc(9*sizeof(node1)); } /* These statements initialize pockets */ for(j = 1; j <= m ; j++) { for(i = 0 ; i < 10 ; i++) { pocket[i] = NULL; pocket1[i] = NULL ; } r = rec ; while(r != NULL) { int dig = digit(r->data, j); nex = r->next ; update(dig,r); r = nex; } if(r!= NULL) { int dig = digit(r->data,j); update(dig,r); } while(pocket1[poc] == NULL) poc ++; rec = Make_link(poc, rec); } return(rec); }
bool infinite_precition :: ispalind( ){ temp_5_ = numdig(); // Analiza la cantidad de digitos del numero if( temp_5_%9==0 ){ temp_6_ = temp_5_/9; } else{ temp_6_ = temp_5_/9+1; } ostvar_1_.str(std::string()); // Vaciamos for( long i=temp_6_-1; i>=0; i-- ){ ostvar_1_<<data_[i]; } strvar_1_ = ostvar_1_.str(); temp_2_ = strvar_1_.length(); for( unsigned int i=0; i<temp_2_; i++ ){ if( strvar_1_[i]!=strvar_1_[temp_2_-1-i] ){ return false; } } return true; }
int Big::len() const { return numdig(fn); }
void infinite_precition :: reverse( infinite_precition* lhs ){ temp_5_ = numdig(); // Analiza la cantidad de digitos del numero if( temp_5_%9==0 ){ temp_6_ = temp_5_/9; } else{ temp_6_ = temp_5_/9+1; } // Borrar lhs lhs->setvalue(0); ostvar_1_.str(std::string()); // Vaciamos temp_7_ = 0; // Para agregarle ceros for( long i=temp_6_-1; i>=0; i-- ){ // // ostvar_1_.str(std::string()); // Vaciamos temp_1_ = 0; if( i!=temp_6_-1 ){ if( data_[i] >= 1000000000 ){ cout<<endl<<"Hay algun error, ningun puede ser mayor q 1000000000"; abort(); } else if( data_[i] >= 100000000 ){ temp_1_ = 0; } else if( data_[i] >= 10000000 ){ temp_1_ = 1; // break; } else if( data_[i] >= 1000000 ){ temp_1_ = 2; // break; } else if( data_[i] >= 100000 ){ temp_1_ = 3; // break; } else if( data_[i] >= 10000 ){ temp_1_ = 4; // break; } else if( data_[i] >= 1000 ){ temp_1_ = 5; // break; } else if( data_[i] >= 100 ){ temp_1_ = 6; // break; } else if( data_[i] >= 10 ){ temp_1_ = 7; // break; } else if( data_[i] >= 1 ){ temp_1_ = 8; } else if( data_[i] == 0 ){ temp_1_ = 0; } for( unsigned long long j=0; j<temp_1_; j++ ){ ostvar_1_<<temp_7_; } } ostvar_1_<<data_[i]; } temp_2_ = temp_5_%9; temp_1_ = 0; if( temp_2_!=0 ){ for( unsigned long long i=0; i<9-temp_2_; i++ ){ ostvar_1_<<temp_1_; // cout<<endl<<"YY: "; } } strvar_1_ = ostvar_1_.str(); // NUNCA JAMAS SUPE COMO HACER EL CAMBIO DE STRING A NUMERO, NO SE SI USANDO LA VARIABLE NICO, O COMO CARAJOS UTILIZAR LA FUNCION ATOI, CUANDO TENEMOS UN STRING LARGO Y YO QUIERO HACER LA CONVERSION CARACTER A CARACTER, // const char* nico = ostvar_1_.str().c_str(); for( unsigned long long i=0; i<temp_6_; i++ ){ temp_1_ = 0; temp_5_ = 0; for( unsigned long long j=i*9; j<(i+1)*9; j++ ){ // temp_2_ = nico[j]-48; temp_2_ = strvar_1_[j]-48; // temp_2_ = atoi(&strvar_1_[j]); temp_1_ = temp_1_ + temp_2_*pow(10,temp_5_); temp_5_++; } lhs->setvalue(i+1,temp_1_); } }