#include <iostream>
using namespace std;
int n = 10,dd[10] ;
int kq[11];
void Hv(int step)
{
int sum = 0;
for(int i = 1; i < step; i++)
sum = sum + kq[i];
if( sum == 10)
{
for (int j=1; j<step; j++)
cout<< kq[j]<<" ";
cout << endl;
return;
}
if (sum<10){
for (int j=1; j<=10; j++)
if (dd[j]==0)
{
dd[j]=1;
kq[step]=j;
Hv(step+1);
dd[j]=0;
}
}
}
int main()
{
for (int i=1; i<=10; i++)
dd[i]=0;
Hv(1);
return 0;
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.