I have a school project due next week and I'm trying to crack the way to solve this question. The problem was to develop a program that test my previous one, which had to print the 2 smallest numbers out of 4 using if-switch. What I need to test:
if (a>b) {
int tmp = b;
b = a;
a = tmp;
}
if (b>c) {
int tmp = c;
c = b;
b = tmp;
}
if (a>d) {
int tmp = d;
d = a;
a = tmp;
}
if (b>d) {
int tmp = d;
d = b;
b = tmp;
}
My limitations are:
- Must only use: int, for,while, if, scanner (so no break or arrays/Boolean/etc)
- No user input, must enter to test a,d=0 c,b=1.
- I know there are 16 options, if all are true, then print verified, in any case there must be written in the tester a code that prints 1 example if false
I'm trying to solve this with for statements, however I only got as far as just printing 1+2,3+4... in: for (int i=0; i<=16 ; i++).
- How do I check the numbers they want (0,1) over and over in for loop?
- I would appreciate a hint on printing just 1 example for the false print
Aucun commentaire:
Enregistrer un commentaire