>>1
Here's a CL solution that reuses a macro I wrote a long time ago, with a small twist:
(defmacro with-same-measurement-units (source unit-bindings &body body)
(destructuring-bind (first second . rest) unit-bindings
(let ((units (list (car second) (car first))))
`(multiple-value-bind ,(reverse units) (truncate ,source ,(second first))
,@(if rest
`((with-same-measurement-units
,(first units) ,(cons second rest) ,@body))
body)))))
I was thinking of something of a simpler scale though, as decoding them drives me insane.
Name:
OP2010-05-01 6:47
OP again. What I was looking for is a simple Input/Output program where you put in a whole number, then the program will compute for the least amount of ones, fives and tens.
Given example:
Input:24
Output:
Tens:2
Fives:0
Ones:4
may be borked; if it is, your new homework assignment is to fix it #include <stdio.h>
#include <ctype.h>
char numberin[9];
int number;
int tens = 0;
int fives = 0;
int ones = 0;
int main(int argc, char *argv[])
{
/* dear */
auto long int s,i,r; /* please */
auto long int* g = null;
auto long int t = (i-(r=i%10))/10;
auto long int f = (r-(s=r%5))/5;
auto long int o = s;
printf("| %s %l | %s %l | %s %l |\n","tens:",t,"fives:",f,"ones:",o);
return 0;
}
int main(){
int number_to_be_analyzed;
printf("Give to me an integer: ");
scanf("%i", &number_to_be_analyzed);
crunch(number_to_be_analyzed);
return(1);
}
>>2,3,13
Do you also perform of a and b with while (a > 0) b++;?
I know a lot of you are trolling, but a problem this simple shouldn't go this long without a correct solution.
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
int num;
if (argc < 2) {
fprintf(stderr, "No number provided.\n");
return 1;
}
num = atoi(argv[1]);
printf("Tens:\t%d\nFives:\t%d\nOnes:\t%d\n",
num / 10, num % 10 >= 5, num % 5);