Pagini recente » Cod sursa (job #1883705) | Cod sursa (job #1189688) | Cod sursa (job #136435) | Cod sursa (job #586721) | Cod sursa (job #2894864)
#include <bits/stdc++.h>
using namespace std;
ifstream in("loto.in");
ofstream out("loto.out");
struct perechi{
int x, y, z;
};
unordered_map <int, perechi> loterie;
int nrLoterie, Suma, v[101], ok = 0;
int main() {
in >> nrLoterie >> Suma;
for (int i = 0; i < nrLoterie; i++)
in >> v[i];
for (int i = 0; i < nrLoterie; i++)
for (int j = i; j < nrLoterie;j ++)
for (int k = j; k < nrLoterie; k++)
{
perechi numar;
numar.x = v[i];
numar.y = v[j];
numar.z = v[k];
loterie.insert(make_pair(v[i] + v[j] + v[k], numar));
}
for (int i = 0; i < nrLoterie; i++)
for (int j = i; j < nrLoterie; j++)
for (int k = j; k < nrLoterie; k++)
if (loterie.find(Suma - (v[i] + v[j] + v[k])) != loterie.end())
{
out << loterie[Suma - v[i] - v[j] - v[k]].x << " " << loterie[Suma - v[i] - v[j] - v[k]].y << " " << loterie[Suma - v[i] - v[j] - v[k]].z << " " <<
loterie[Suma - v[i] - v[j] - v[k]].x << " " << loterie[Suma - v[i] - v[j] - v[k]].y << " " << loterie[Suma - v[i] - v[j] - v[k]].z;
}
return 0;
}