Advertisement
Aslai

Untitled

Feb 18th, 2012
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. int main(){
  3.     char in[1000];
  4.     struct{int carry;int times;} list[] = { {0,0}, {20,3}, {40,6}, {60,9}, {10,2}, {30,5}, {50,8}, {0,1}, {20,4}, {40,7} };
  5.     printf("Target: ");
  6.     gets(in);
  7.     int target = strtol( in, 0, 10 ), j, i,save[4];
  8.     for( i = 3; i >= 0; --i ){
  9.         j = target - target / 10 * 10;
  10.         save[i] = list[j].times;
  11.         target = ( target - list[j].carry ) / 10;
  12.     }
  13.     for( i = 0; i < 4; ++i )
  14.         printf("%i%c", save[i], i < 3 ? '>' : ' ' );
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement