100% Working C++ Tambola/Housie Code with 90 Unique Numbers

#include<iostream>

#include<iomanip>

#include<time.h>

#include<stdlib.h>

#include<windows.h>

using namespace std;

int static tktno=1;

void housiedesign()

{

cout<<"Welcome to Royale...\n";

cout<<setw(30)<<"               HH    HH    OOOOO     UU     UU   SSSSS   II  EEEEEEE \n";

cout<<setw(30)<<"               HH    HH   OO    OO   UU     UU  SS       II  EE      \n";

cout<<setw(30)<<"               HHHHHHHH  OO      OO  UU     UU   SSSSS   II  EEEEEEE \n";

cout<<setw(30)<<"               HH    HH   OO    OO    UU   UU        SS  II  EE      \n";

cout<<setw(30)<<"               HH    HH    OOOOO        UUU      SSSSS   II  EEEEEEE \n";

}

void generateRandom()

{

int rng=90;

srand((unsigned)time(NULL));

int i,n=90,j,flag,k,tmp,a[90];

for(i=0,j=0;j<n;i++)

{

tmp=rand()%90+1;

if(i==0)

a[j++]=tmp;

flag=0;

for(k=0;k<j;k++)

{

if(a[k]==tmp)

flag++;

}

if(flag==0)

a[j++]=tmp;

}

cout<<endl;

system("pause");

system("cls");

cout<<"GEAR UP NUMBER STARTS NOW....\n";

system("pause");

int py=0,x=1;

for(i=0;i<90;i++)

{

cout<<a[i]<<endl;

system("pause");

}

}

void tickets()

{

time_t t;

int tickets=0,en=0;

cout<<"Enter Number of tickets you want : ";

cin>>tickets;

srand((unsigned)time(&t));

int arr[tickets];

int tnn=0;

for(en=0;en<tickets;en++)

{

int  j=0,tmp=0,i=0,no[3][9]={0};

int flag=0;

tnn+=1;

arr[en]=tnn;

for(i=0;i<3;i++)

{

for(j=0;j<9;j++)

{

START:

tmp=(rand()%10+1)+(j*10);

if(i==0 && j==0)

no[i][j]=tmp;

else

{

flag=0;

for(int k=0;k<=i;k++)

{

for(int z=0;z<=j;z++)

{

if(no[k][z]==tmp)

flag++;

}

}

}

if(flag==0)

no[i][j]=tmp;

else

goto START;

}

}

int t1, t2, x=0, s, nArr[12]={0};

flag=0;

for(i=0;x<12;i++)

{

middle: 

t1=(rand()%3);

t2=(rand()%9);

s=t1*10+t2;

for(j=0;j<=i;j++)

{

if(s==nArr[j])

flag++;

}

if(flag==0)

{

    nArr[x]=s;

x++;

no[t1][t2]=0;

    }

flag=0;

}

  int si=0,a=0,tmpp=0,sj=0;

  for(i=0;i<3;i++)

{

for(j=0;j<9;j++)

{

si=i+1;

sj=i+2;

if(no[i][j]!=0 && i<2 && no[si][j]!=0)

{

if(no[i][j]>no[si][j])

{

tmpp=no[si][j];

no[si][j]=no[i][j];

no[i][j]=tmpp;

}

}

else if(no[i][j]!=0 && i<1 && no[si][j]!=0 && no[sj][j]!=0)

{

if(no[i][j]>no[si][j])

{

tmpp=no[si][j];

no[si][j]=no[i][j];

no[i][j]=tmpp;

}

else if(no[i][j]>no[sj][j])

{

tmpp=no[sj][j];

no[sj][j]=no[i][j];

no[i][j]=tmpp;

}

else if(no[si][j]>no[sj][j])

{

tmpp=no[sj][j];

no[sj][j]=no[si][j];

no[si][j]=tmpp;

}

    }

if(no[i][j]!=0 && i<1 && no[sj][j]!=0)

{

if(no[i][j]>no[sj][j])

{

tmpp=no[sj][j];

no[sj][j]=no[i][j];

no[i][j]=tmpp;

}

}

if(no[si][j]!=0 && i<1 && no[sj][j]!=0)

{

if(no[si][j]>no[ sj][j])

{

tmpp=no[sj][j];

no[sj][j]=no[si][j];

no[si][j]=tmpp;

}

}

}

}

int fag=0;

fag=0;

for(i=0;i<3;i++)

{

for(j=0;j<9;j++)

{

if(i==0)

{

if(no[i][j]==0 && no[i+1][j]==0 && no[i+2][j]==0 )

{

goto START;

fag++;

}

}

}

}

int tn=0;

if(fag==0)

{

cout<<"=========================================================\n";

cout<<setw(35)<<"Ticket NO : #"<<tktno++<<endl;

cout<<"=========================================================\n";

for(i=0;i<3;i++)

{

cout<<"---------------------------------------------------------\n";

for(j=0;j<9;j++)

{

Sleep(10);

if(no[i][j]!=0)

{

cout<<setw(3)<<"|"<<setw(3)<<no[i][j];

}

else

{

cout<<setw(3)<<"|"<<setw(3)<<" ";

}

}

cout<<setw(3)<<"|"<<endl;

}

cout<<"---------------------------------------------------------\n\n";

}

}

}

int main()

{

housiedesign();

tickets();

generateRandom();

}

Comments