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