Solution
This questions is equivalent to computing missing rings no more than 10
#include <iostream>
using namespace std;
void shoot(int &total, int sum, int time)
{
int i;
if(time == 9){
for( i = 0; i < 11; i ++){
if(sum + i < 11){
total ++;
}
}
//cout << "total number is: " << total << endl;
return;
}
for(i = 0; i < 10; i++)
{
if(i + sum < 11){
shoot(total, i + sum, time + 1);
}
}
}
Probem
When a athlete shoots 10 times, compute the possibility of getting 90, how many times can he make it
int main(int argc, char* argv[])
{
int total = 0;
shoot(total, 0, 1);
cout << "total number is: " << total << endl;
return 0;
}
Output
total number is: 92370