There are 1000 apples and 10 baskets, and the basket is numbered 1-10. Now put these 1000 apples into these 10 baskets, asking:
(1) Any 1 digits from 1-1000, which can be made up of apples of some baskets in 10 baskets.
(2) The apple in the basket is a whole, can not take part of the basket of apples, that is, once a basket is selected, the number of the basket must be counted in all.
Code:
#include <iostream>
using namespace Std;
int Main ()
{&NBSP;
int a[10]={1,2,4,8,16,32,64,128,256,489};
int x;
int b=0,c=1,e=1; // B and C are a comparison of the number of input apples to the array, the E-loop
while (x!=0) {
//Compare if there is the same, exit the loop again for output results
if (x==a[b]| | X==a[c] {
cout<< "Number of apples:" <<X<<ENDL;
e=0;
}
if (e==0)
break;
Compare one by one
if (X>=a[b]&&x<=a[c]) {
X=X-A[B];
cout<< "Number of apples:" <<a[b]<<endl;
B=-1;
c=0;
}
++b;
++c;
}
cout <<endl<< "Hello World" <<endl;
return 0;
}
:
1000 Apples and 10 baskets