WhenKittensATK Posted January 24, 2010 Posted January 24, 2010 (edited) Solved. thanks Edited February 10, 2011 by Krazyxazn Share this post Link to post Share on other sites More sharing options...
WhenKittensATK Posted January 26, 2010 Posted January 26, 2010 Updated I still need help with the realloc. Also any ideas on how to make the Compare function more in depth. Currently it only compares the last digit of the array (which is the first, it's reversed in the array) and the length of digits. That can only work for certain conditions. So, I need to figure out a way to compare all the digits in case two numbers have the same last digit and same length. Any suggestions or hints? Ex. 1000 in the array looks like 0001, so it compares the last digit which is the first digit. Changelog (1/26/10) Fixed typos Edited Add function Wrote Subtract and Compare function Added more comments Share this post Link to post Share on other sites More sharing options...
CheeseMan42 Posted January 27, 2010 Posted January 27, 2010 You could iterate through both arrays simultaneously and compare them digit by digit. If you find one thats different, then they aren't the same. Share this post Link to post Share on other sites More sharing options...
WhenKittensATK Posted January 27, 2010 Posted January 27, 2010 (edited) Solved. thanks Edited February 10, 2011 by Krazyxazn Share this post Link to post Share on other sites More sharing options...
CheeseMan42 Posted January 27, 2010 Posted January 27, 2010 When you do printf, try it like this: printf("%d", number); The %d should format it as an integer and hopefully remove the leading zeros. Share this post Link to post Share on other sites More sharing options...
WhenKittensATK Posted January 28, 2010 Posted January 28, 2010 No go with %d for printf. I was able to get the highest number to be subtracted by the lower number with some help. So I'll just leave my compare function the way it is and just not call it . He never said we had to use it . Now I got a few more hours to figure out how to properly print out the code. INPUT2 2 9999999999 10000000000 2 10000000000 9999999999 OUTPUT0-1-1-1-1-1-1-1-1-10 - 9999999999 = 00000000001 0-1-1-1-1-1-1-1-1-10 - 9999999999 = 00000000001 I tried replacing the part of the code that adds in the zeros to take over blank spaces of uneven arrays with NULLs instead of zeros, but the leading zeros will still show up. Share this post Link to post Share on other sites More sharing options...
CheeseMan42 Posted January 28, 2010 Posted January 28, 2010 You could try looping from the left side of that number, where the zeros start, and not do anything until you find a non-zero. After that put all those values into another array and print that out. Share this post Link to post Share on other sites More sharing options...
WhenKittensATK Posted January 28, 2010 Posted January 28, 2010 (edited) Solved. thanks Edited February 10, 2011 by Krazyxazn Share this post Link to post Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now