Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #include <stdio.h>
- #include <windows.h>
- #include <stdlib.h>
- #include <conio.h>
- #define N 200
- using namespace std;
- void gotoxy(int x, int y)
- {
- COORD coord;
- coord.X = x;
- coord.Y = y;
- SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
- }
- void SetColor(short Color)
- {
- HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE); // oppure system("COLOR E9");
- SetConsoleTextAttribute(hCon,Color);
- }
- void sfondo(){
- system("color 70");
- }//sfondo
- /*Funzioni di controllo*/
- //------------------------------------------------------------------------------
- bool uscito(int a[], int b){
- for(int i=1;i<=90;i++)
- if(a[i]==b)
- return true;
- return false;
- }//uscito
- bool isNeg(int a[]){
- for(int i=1;i<=90;i++)
- if(a<0)
- return true;
- return false;
- }//isNeg
- //------------------------------------------------------------------------------
- /*Inizializzazione cartelle e tombola*/
- //------------------------------------------------------------------------------
- void cartella(int y[]){
- srand(time(NULL));
- int h,h2;
- for(int i=1;i<=10;i++){
- h=rand()%(90)+1;
- h2=rand()%((h-7))+1;
- if(!(uscito(y,h2))&&!(isNeg(y)))
- y[i]=h2;
- else
- i--;
- }//for
- }//cartella
- void cartella1(int z[]){
- srand(time(NULL));
- int c,c2;
- for(int i=1;i<=10;i++){
- c=rand()%(90)+1;
- c2=rand()%((c-3))+1;
- if(!(uscito(z,c2))&&!(isNeg(z)))
- z[i]=c2;
- else
- i--;
- }//for
- }//cartella1
- void tombola(int a[]){
- srand(time(NULL));
- int b;
- for(int i=1;i<=90;i++){
- b=rand()%(90-1+1)+1;
- if(!(uscito(a,b)))
- a[i]=b;
- else
- i--;
- }//for
- }//tombola
- //------------------------------------------------------------------------------
- /*Stampa cartelle e tombola*/
- //------------------------------------------------------------------------------
- void stcart(int y[]){
- cout<<"\n\nLa tua cartella e`:\n\n";
- for(int i=1;i<=10;i++)
- cout<<y[i]<<"\t";
- }//stcart
- void stcart1(int z[]){
- cout<<"\n\nLa cartella del computer e`:\n\n";
- for(int i=1;i<=10;i++)
- cout<<z[i]<<"\t";
- }//stcart
- int estraz(int a[], int y[], int z[]/*, int *ambo, int *terno, int *cinq*/){
- int c=0;
- int t=0;
- cout<<"\n\n\t\t\tProcediamo con le estrazioni: \n\n";
- for(int i=1;i<=90;i++){
- Sleep(80);
- cout<<a[i]<<"\t";
- for(int j=1;j<=10;j++){
- if(a[i]==y[j]){
- t++;
- if(t==13)
- return t;
- }//if
- if(a[i]==z[j]){
- c--;
- if(c==-10)
- return c;
- }//if
- if(t==2){
- cout<<"\nhai fatto ambo! ";
- getchar();
- t++;
- }//if
- if(t==4){
- cout<<"\nhai fatto terno! ";
- getchar();
- t++;
- }//if
- if(t==6){
- cout<<"\nhai fatto cinquina! ";
- getchar();
- t++;
- }//if
- }//for-j
- }//for-i
- }//stampa
- void vinto(int win){
- if(win==13)
- cout<<"\n\n\t\t\tHai vinto :D";
- else
- cout<<"\n\n\t\t\tHa vinto il computer :(";
- }//vinto
- //------------------------------------------------------------------------------
- int main(){
- int a[N],y[N],z[N];
- sfondo();
- cartella(y);
- stcart(y);
- cartella1(z);
- stcart1(z);
- tombola(a);
- vinto(estraz(a,y,z));
- fflush(stdin);
- getchar();
- return 0;
- }//main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement