Cod sursa(job #1196979)

Utilizator razvang10Razvan Girboveanu razvang10 Data 10 iunie 2014 08:44:23
Problema Loto Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.94 kb
#include <iostream>
#include <fstream>
using namespace std;
int main ()
{
    ifstream si("loto.in");
    ofstream so("loto.out");
    int n,S,a,b,c,d,e,f,C=0;
    si>>n>>S;
    for (a=1;a<=n;a++)
    {
           for (b=1;b<=n;b++)
        {
                for (c=1;c<=n;c++)
            {
                    for (d=1;d<=n;d++)
                {
                        for (e=1;e<=n;e++)
                    {
                            for (f=1;f<=n;f++)
                        {
                            if ((a+b+c+d+e+f)==S)
                            {
                                so<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<" "<<f<<" "<<endl;
                                return 0;
                                C=1;
                            }
                        }
                    }
                }
            }
        }
    }
    if (C==0)
    {
        so<<"-1";
    }
    return 0;
}