Pagini recente » Cod sursa (job #1059476) | Cod sursa (job #45472) | Cod sursa (job #2634275) | Cod sursa (job #2435342) | Cod sursa (job #1780647)
#include <fstream>
using namespace std;
ifstream f("loto.in");
ofstream g("loto.out");
int n,s,x[101];
int main()
{ f>>n>>s;
for(int i=1;i<=n;i++) f>>x[i];
int w=1;
for(int i=1;i<=n and w;i++)
for(int j=1;i<=n and w;j++)
for(int k=1;k<=n and w;k++)
for(int l=1;l<=n and w;l++)
for(int p=1;p<=n and w;p++)
for(int q=1;q<=n and w;q++)
{ int sum=x[i]+x[j]+x[k]+x[l]+x[p]+x[q];
if(sum==s) {g<<x[i]<<' '<<x[j]<<' '<<x[k]<<' '<<x[l]<<' '<<x[p]<<' '<<x[q]; w=0; }
}
if(w) g<<-1;
g.close();
return 0;
}