Advertisement
robonx12

Fucking epic number machine No. 2

Jun 9th, 2015
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.69 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <stdbool.h>
  4. #include <string.h>
  5.  
  6. #define MAX 15
  7.  
  8. bool Transfer(int, char *, int);
  9.  
  10. int main(int argc, char **argv) {
  11.     char string[MAX];
  12.     memset(string, '\0', sizeof(char) * MAX);
  13.     Transfer(atoi(argv[1]), string, atoi(argv[2]));
  14.     strrev(string);}
  15.     printf("%s", string);
  16.  
  17. }
  18.  
  19. bool Transfer(int number, char *string, int sys) {
  20.     int rest;
  21.     int counter = 0;
  22.     while(1) {
  23.         if ((rest = number % sys) >= 10) {
  24.             string[counter] = rest + 55;
  25.         } else {
  26.             string[counter] = rest + 48;
  27.         }
  28.         if ((number = number / sys) == 0) {
  29.             return true;
  30.         }
  31.         if ((number != 0 && counter >= MAX - 1)) {
  32.             return false;
  33.         }
  34.         counter++;
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement