Pagini recente » Cod sursa (job #2943263) | Cod sursa (job #774915) | Cod sursa (job #150231) | Cod sursa (job #959307) | Cod sursa (job #69118)
Cod sursa(job #69118)
#include<fstream.h>
long a[100],T;
ofstream fout("loto.out");
short n;
void citire(){
ifstream fin("loto.in");
fin>>n>>T;
for (short i=0;i<n;i++)
fin>>a[i];
fin.close();
}
void bule(){
short ok=0,p=n;
while(ok==0){
ok=1;
p--;
for (short i=0;i<p;i++)
if (a[i]>a[i+1]){
long aux=a[i];
a[i]=a[i+1];
a[i+1]=aux;
ok=0;}
}
}
int parc(){
long S;
for (short i=0;i<n;i++)
for (short j=0;j<n;j++)
for (short k=0;k<n;k++)
for (short l=0;l<n;l++)
for (short o=0;o<n;o++)
for (short u=0;u<n;u++)
if (a[i]+a[j]+a[k]+a[l]+a[o]+a[u]==T){
fout<<a[i]<<" "<<a[j]<<" "<<a[k]<<" "<<a[l]<<" "<<a[o]<<" "<<a[u]<<"\n";
return 1;}
return 0;
}
int main(){
citire();
bule();
if (parc()==0)
fout<<"-1";
return 0;
}