Page 1 of 1

Joc in C++ 6/49

Posted: 27 Oct 2018, 16:59
by BGY95
#include <iostream>
#include <cstdlib>
#include <ctime>
#define culoare5A system("color 5A")
#define clear system("cls")
using namespace std;



int main()
{

culoare5A;
int a[6],i,n[6], gasite=0, raspuns, vector[6], indice=1, salveazaNR;
bool alegere = true, dublura = false;
while (alegere)
{
cout << "Pune biletul 6/49:\n";
srand(time(NULL));
for (i=0;i<6;i++)
a[i]=(rand()%49)+1;


for (i=0;i<6;i++)
for (int j=i+1;j<6;j++)
if (a[i]==a[j])
{
dublura = true;
salveazaNR = a[i];
}

if (dublura==true)
{
clear;
cout << "INFO_EROARE\nPe noul bilet a fost generat ";
cout << "numarul "<< salveazaNR << " de doua ori. Reporniti programul!\n";
cout << "Ai jucat " << indice-1 << " bilete pana acum.\n";
system("pause");
exit(1);
}




for (i=0;i<6;i++)
cin >> n[i];

for (i=0;i<6;i++)
for (int k=0;k<6;k++)
if(a[i]==n[k])
{
gasite+=1;
vector[gasite-1] = a[i];
}
clear;
cout << "Numerele extrase sunt: ";
for (i=0;i<6;i++)
cout << a[i] << " ";
cout << "\nNumerele puse: ";
for (i=0;i<6;i++)
cout << n[i] << " ";
cout << "\nNumerele prinse: ";
for (i=0;i<gasite;i++)
cout << vector[i]<<" ";
if (gasite==0) cout << "nici un numar" << endl;
cout << "\n\nMai pui un bilet?\n1 = Afirmativ, 0 = Negativ"<<endl;
cin >> raspuns;
if (raspuns==1)
{
clear;
indice+=1;
cout << "Ai ales sa mai pui un bilet." << endl;
gasite=0;
}
if (raspuns==0)
{
clear;
cout << "Ai ales sa nu mai joci." << endl;
cout << "Ai jucat " << indice << " bilete.";
cout << "\nE-MAIL: butnaru.gheorghita@yahoo.com";
alegere = false;



}
if (raspuns!=0 && raspuns!=1)
{
clear;
cout << "Comanda necunoscuta!";
exit(1);
}


}
}