📜 ⬆️ ⬇️

About recursive procedures

Greetings to you, Habrole

It will focus on the virtues of recursive procedures.


The function, as we know, takes arguments and returns a value depending on them. It usually has the form y = f (x1, ... xn);
However, she should not commit any side effects. Because in that case it will be called a procedure.
The procedure may look something like this:
')
Copy Source | Copy HTML void someProc ( x1,...xn ) { doDomething1(); ... doSomethingN(); }
Copy Source | Copy HTML void someProc ( x1,...xn ) { doDomething1(); ... doSomethingN(); }
  1. Copy Source | Copy HTML void someProc ( x1,...xn ) { doDomething1(); ... doSomethingN(); }
  2. Copy Source | Copy HTML void someProc ( x1,...xn ) { doDomething1(); ... doSomethingN(); }
  3. Copy Source | Copy HTML void someProc ( x1,...xn ) { doDomething1(); ... doSomethingN(); }
  4. Copy Source | Copy HTML void someProc ( x1,...xn ) { doDomething1(); ... doSomethingN(); }
  5. Copy Source | Copy HTML void someProc ( x1,...xn ) { doDomething1(); ... doSomethingN(); }
  6. Copy Source | Copy HTML void someProc ( x1,...xn ) { doDomething1(); ... doSomethingN(); }
Copy Source | Copy HTML void someProc ( x1,...xn ) { doDomething1(); ... doSomethingN(); }


That is, just follow a few steps. It can do very well with no arguments or no return value.

If we organize a call to the function itself (recursion), then, as a rule,
use the return value for intermediate calculations. For example, calculate the factorial or process the list.

A nagging example of factorial, but necessary for illustration:

Copy Source | Copy HTML int fac( n ) { if( n == 0 ) return 1 ; return n * fac( n-1 ); }
Copy Source | Copy HTML int fac( n ) { if( n == 0 ) return 1 ; return n * fac( n-1 ); }
  1. Copy Source | Copy HTML int fac( n ) { if( n == 0 ) return 1 ; return n * fac( n-1 ); }
  2. Copy Source | Copy HTML int fac( n ) { if( n == 0 ) return 1 ; return n * fac( n-1 ); }
  3. Copy Source | Copy HTML int fac( n ) { if( n == 0 ) return 1 ; return n * fac( n-1 ); }
  4. Copy Source | Copy HTML int fac( n ) { if( n == 0 ) return 1 ; return n * fac( n-1 ); }
  5. Copy Source | Copy HTML int fac( n ) { if( n == 0 ) return 1 ; return n * fac( n-1 ); }
  6. Copy Source | Copy HTML int fac( n ) { if( n == 0 ) return 1 ; return n * fac( n-1 ); }
Copy Source | Copy HTML int fac( n ) { if( n == 0 ) return 1 ; return n * fac( n-1 ); }


An example, though given in C, is made in a purely functional approach.

And what can a recursive procedure give us? It has a very good feature, namely: the space BEFORE calling itself and AFTER.
And the fact that AFTER, is performed for the first time at the exact moment when the condition for exit from recursion is met (in the simple case).

Copy Source | Copy HTML void recProc( .... ) { // recProc( ... ); // - , }
Copy Source | Copy HTML void recProc( .... ) { // recProc( ... ); // - , }
  1. Copy Source | Copy HTML void recProc( .... ) { // recProc( ... ); // - , }
  2. Copy Source | Copy HTML void recProc( .... ) { // recProc( ... ); // - , }
  3. Copy Source | Copy HTML void recProc( .... ) { // recProc( ... ); // - , }
  4. Copy Source | Copy HTML void recProc( .... ) { // recProc( ... ); // - , }
  5. Copy Source | Copy HTML void recProc( .... ) { // recProc( ... ); // - , }
  6. Copy Source | Copy HTML void recProc( .... ) { // recProc( ... ); // - , }
Copy Source | Copy HTML void recProc( .... ) { // recProc( ... ); // - , }


That is, the recursive procedure can be compared with a spring, which is twisted first, and then unwound to its original position.
We illustrate by example. Let's say the task is to print the numbers from 0 to N without using a loop.

Here is the procedure:

Copy Source | Copy HTML void cnt( int i ) { if( i ) { // printf("%d\n",i); // cnt( i-1 ); } printf( "%d\n",i ); // }
Copy Source | Copy HTML void cnt( int i ) { if( i ) { // printf("%d\n",i); // cnt( i-1 ); } printf( "%d\n",i ); // }
  1. Copy Source | Copy HTML void cnt( int i ) { if( i ) { // printf("%d\n",i); // cnt( i-1 ); } printf( "%d\n",i ); // }
  2. Copy Source | Copy HTML void cnt( int i ) { if( i ) { // printf("%d\n",i); // cnt( i-1 ); } printf( "%d\n",i ); // }
  3. Copy Source | Copy HTML void cnt( int i ) { if( i ) { // printf("%d\n",i); // cnt( i-1 ); } printf( "%d\n",i ); // }
  4. Copy Source | Copy HTML void cnt( int i ) { if( i ) { // printf("%d\n",i); // cnt( i-1 ); } printf( "%d\n",i ); // }
  5. Copy Source | Copy HTML void cnt( int i ) { if( i ) { // printf("%d\n",i); // cnt( i-1 ); } printf( "%d\n",i ); // }
  6. Copy Source | Copy HTML void cnt( int i ) { if( i ) { // printf("%d\n",i); // cnt( i-1 ); } printf( "%d\n",i ); // }
  7. Copy Source | Copy HTML void cnt( int i ) { if( i ) { // printf("%d\n",i); // cnt( i-1 ); } printf( "%d\n",i ); // }
  8. Copy Source | Copy HTML void cnt( int i ) { if( i ) { // printf("%d\n",i); // cnt( i-1 ); } printf( "%d\n",i ); // }
Copy Source | Copy HTML void cnt( int i ) { if( i ) { // printf("%d\n",i); // cnt( i-1 ); } printf( "%d\n",i ); // }


It indicates the output - if i becomes zero. Each time, it is called with the argument reduced by one. As soon as she volunteered with zero, i is printed. And a way out. But it turns out that it is still in itself and at the previous iteration.
As a result, we get the printing of numbers from 0 to the given argument. Spring tightened and dissolved. We are seeing the process of dissolution just.

If you uncomment the line BEFORE the entry, and AFTER comment out, we get a countdown. If you uncomment everything, you get a palindrome. First, the descending sequence (twisting), and then increasing (dissolution).

This feature can be found and more useful application. For example, consider the problem of converting a number to a string. The method consists in the fact that we successively obtain the digits that make up the number, transform them into signs, and from them we make up the line.

For example, the number 496 in the decimal system is decomposed as follows:
496% 10 (take the remainder of the division by base) = 6
49% 10 (divide what remains from the previous division) = 9
4% 10 = 4

The method has 2 drawbacks:
1. We get the numbers from the end
2. We do not know how long the number is.

Kernigan and Richie suggested the following solution:

Copy Source | Copy HTML void itoa( int n, char s[] ) { int i , sign; if ( (sign = n ) < 0 ) /* */ n = -n; /* n */ i = 0 ; do { /* */ s[ i ++] = n % 10 + '0' ; /* */ } while ( (n /= 10 ) > 0 ); /* */ if ( sign < 0 ) s[ i ++] = '-' ; s[ i ] = '\0' ; reverse( s ); }
Copy Source | Copy HTML void itoa( int n, char s[] ) { int i , sign; if ( (sign = n ) < 0 ) /* */ n = -n; /* n */ i = 0 ; do { /* */ s[ i ++] = n % 10 + '0' ; /* */ } while ( (n /= 10 ) > 0 ); /* */ if ( sign < 0 ) s[ i ++] = '-' ; s[ i ] = '\0' ; reverse( s ); }
  1. Copy Source | Copy HTML void itoa( int n, char s[] ) { int i , sign; if ( (sign = n ) < 0 ) /* */ n = -n; /* n */ i = 0 ; do { /* */ s[ i ++] = n % 10 + '0' ; /* */ } while ( (n /= 10 ) > 0 ); /* */ if ( sign < 0 ) s[ i ++] = '-' ; s[ i ] = '\0' ; reverse( s ); }
  2. Copy Source | Copy HTML void itoa( int n, char s[] ) { int i , sign; if ( (sign = n ) < 0 ) /* */ n = -n; /* n */ i = 0 ; do { /* */ s[ i ++] = n % 10 + '0' ; /* */ } while ( (n /= 10 ) > 0 ); /* */ if ( sign < 0 ) s[ i ++] = '-' ; s[ i ] = '\0' ; reverse( s ); }
  3. Copy Source | Copy HTML void itoa( int n, char s[] ) { int i , sign; if ( (sign = n ) < 0 ) /* */ n = -n; /* n */ i = 0 ; do { /* */ s[ i ++] = n % 10 + '0' ; /* */ } while ( (n /= 10 ) > 0 ); /* */ if ( sign < 0 ) s[ i ++] = '-' ; s[ i ] = '\0' ; reverse( s ); }
  4. Copy Source | Copy HTML void itoa( int n, char s[] ) { int i , sign; if ( (sign = n ) < 0 ) /* */ n = -n; /* n */ i = 0 ; do { /* */ s[ i ++] = n % 10 + '0' ; /* */ } while ( (n /= 10 ) > 0 ); /* */ if ( sign < 0 ) s[ i ++] = '-' ; s[ i ] = '\0' ; reverse( s ); }
  5. Copy Source | Copy HTML void itoa( int n, char s[] ) { int i , sign; if ( (sign = n ) < 0 ) /* */ n = -n; /* n */ i = 0 ; do { /* */ s[ i ++] = n % 10 + '0' ; /* */ } while ( (n /= 10 ) > 0 ); /* */ if ( sign < 0 ) s[ i ++] = '-' ; s[ i ] = '\0' ; reverse( s ); }
  6. Copy Source | Copy HTML void itoa( int n, char s[] ) { int i , sign; if ( (sign = n ) < 0 ) /* */ n = -n; /* n */ i = 0 ; do { /* */ s[ i ++] = n % 10 + '0' ; /* */ } while ( (n /= 10 ) > 0 ); /* */ if ( sign < 0 ) s[ i ++] = '-' ; s[ i ] = '\0' ; reverse( s ); }
  7. Copy Source | Copy HTML void itoa( int n, char s[] ) { int i , sign; if ( (sign = n ) < 0 ) /* */ n = -n; /* n */ i = 0 ; do { /* */ s[ i ++] = n % 10 + '0' ; /* */ } while ( (n /= 10 ) > 0 ); /* */ if ( sign < 0 ) s[ i ++] = '-' ; s[ i ] = '\0' ; reverse( s ); }
  8. Copy Source | Copy HTML void itoa( int n, char s[] ) { int i , sign; if ( (sign = n ) < 0 ) /* */ n = -n; /* n */ i = 0 ; do { /* */ s[ i ++] = n % 10 + '0' ; /* */ } while ( (n /= 10 ) > 0 ); /* */ if ( sign < 0 ) s[ i ++] = '-' ; s[ i ] = '\0' ; reverse( s ); }
  9. Copy Source | Copy HTML void itoa( int n, char s[] ) { int i , sign; if ( (sign = n ) < 0 ) /* */ n = -n; /* n */ i = 0 ; do { /* */ s[ i ++] = n % 10 + '0' ; /* */ } while ( (n /= 10 ) > 0 ); /* */ if ( sign < 0 ) s[ i ++] = '-' ; s[ i ] = '\0' ; reverse( s ); }
  10. Copy Source | Copy HTML void itoa( int n, char s[] ) { int i , sign; if ( (sign = n ) < 0 ) /* */ n = -n; /* n */ i = 0 ; do { /* */ s[ i ++] = n % 10 + '0' ; /* */ } while ( (n /= 10 ) > 0 ); /* */ if ( sign < 0 ) s[ i ++] = '-' ; s[ i ] = '\0' ; reverse( s ); }
  11. Copy Source | Copy HTML void itoa( int n, char s[] ) { int i , sign; if ( (sign = n ) < 0 ) /* */ n = -n; /* n */ i = 0 ; do { /* */ s[ i ++] = n % 10 + '0' ; /* */ } while ( (n /= 10 ) > 0 ); /* */ if ( sign < 0 ) s[ i ++] = '-' ; s[ i ] = '\0' ; reverse( s ); }
  12. Copy Source | Copy HTML void itoa( int n, char s[] ) { int i , sign; if ( (sign = n ) < 0 ) /* */ n = -n; /* n */ i = 0 ; do { /* */ s[ i ++] = n % 10 + '0' ; /* */ } while ( (n /= 10 ) > 0 ); /* */ if ( sign < 0 ) s[ i ++] = '-' ; s[ i ] = '\0' ; reverse( s ); }
  13. Copy Source | Copy HTML void itoa( int n, char s[] ) { int i , sign; if ( (sign = n ) < 0 ) /* */ n = -n; /* n */ i = 0 ; do { /* */ s[ i ++] = n % 10 + '0' ; /* */ } while ( (n /= 10 ) > 0 ); /* */ if ( sign < 0 ) s[ i ++] = '-' ; s[ i ] = '\0' ; reverse( s ); }
  14. Copy Source | Copy HTML void itoa( int n, char s[] ) { int i , sign; if ( (sign = n ) < 0 ) /* */ n = -n; /* n */ i = 0 ; do { /* */ s[ i ++] = n % 10 + '0' ; /* */ } while ( (n /= 10 ) > 0 ); /* */ if ( sign < 0 ) s[ i ++] = '-' ; s[ i ] = '\0' ; reverse( s ); }
Copy Source | Copy HTML void itoa( int n, char s[] ) { int i , sign; if ( (sign = n ) < 0 ) /* */ n = -n; /* n */ i = 0 ; do { /* */ s[ i ++] = n % 10 + '0' ; /* */ } while ( (n /= 10 ) > 0 ); /* */ if ( sign < 0 ) s[ i ++] = '-' ; s[ i ] = '\0' ; reverse( s ); }


That is, they build a line backwards, and then, using the reverse function, turn it over. Decision what is called "in the forehead" and leaves questions.
For example, how much memory to allocate under the line. Sly founding fathers preferred to go around this and write data to an already defined array.
Yes, and turn every line after the conversion - not comme il faut. Because such calls are very frequent and this will undoubtedly affect performance.

This is where the recursive procedure comes in. She is able to transform
10-tichny, 16-trichesky, 2-ical and 8-tric numbers in a string view.

Here's what she looks like:

Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  1. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  2. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  3. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  4. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  5. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  6. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  7. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  8. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  9. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  10. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  11. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  12. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  13. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  14. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  15. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  16. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  17. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  18. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  19. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  20. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  21. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  22. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  23. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  24. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  25. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  26. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  27. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  28. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  29. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  30. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  31. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  32. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  33. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  34. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  35. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  36. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  37. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  38. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  39. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  40. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  41. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  42. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  43. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  44. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  45. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  46. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  47. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  48. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
  49. Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }
Copy Source | Copy HTML #include <stdio.h> #include <stdlib.h> #include <assert.h> #define DEC 0 #define OCT 1 #define HEX 2 #define BIN 3 char *uitoa( int a,int r ); int main() { int num = 7654894 ; int e_num = 0x4E35FF; int b_num = 0b1110011; int o_num = 077432 ; printf( "%s\n",uitoa(e_num,HEX )); printf( "%s\n",uitoa(b_num,BIN )); printf( "%s\n",uitoa(o_num,OCT )); } char *uitoa( int a,int r ) { /* <br/> * <br/> * <br/> * <br/> */ static int szmem = 0 ; // static char *mas = 0 ; // static char *bgmas = 0 ; // char numb [] = "0123456789ABCDEF" ; // 0 - '0', 15 - 'F' int dig[] ={ 10 , 8 , 16 , 2 }; // if( a == 0 ) { if( szmem == 0 ) { // 0 // 2 sizeof(char), 0 ( 0) mas = malloc( 2 * sizeof(char ) ); assert( mas ); *mas = '0' ;*( mas + 1 ) = 0 ; return mas; // } /* , szmem <br/> * a 0 ( ) <br/> * szmem + sizeof(char) 0 <br/> * <br/> */ bgmas = mas = malloc( szmem * sizeof(char ) + size of( char ) ); assert( mas ); *( mas+szmem ) = ( char ) 0 ; }else { /* . a!=0 <br/> * <br/> * <br/> * a <br/> */ szmem++; uitoa( a / dig[r],r ); /* <br/> * , <br/> * , <br/> * . <br/> * <br/> * : , <br/> * "" . <br/> * "" <br/> * , . <br/> * <br/> * <br/> * mas , <br/> * . <br/> */ *mas++ = numb [ a % dig[r]]; } szmem = 0 ; return bgmas; }


The procedure allocates memory and returns a pointer to it. So after receiving the line and after working with it, you should perform the release of memory, in order to avoid memory leak.

I hope someone article will be useful in understanding recursion.

Source: https://habr.com/ru/post/90784/


All Articles