SHOW:
|
|
- or go back to the newest paste.
| 1 | #include <iostream> | |
| 2 | #include <ctime> | |
| 3 | #include <stdio.h> | |
| 4 | #include <windows.h> | |
| 5 | #include <stdlib.h> | |
| 6 | #include <conio.h> | |
| 7 | #define N 200 | |
| 8 | using namespace std; | |
| 9 | void gotoxy(int x, int y) | |
| 10 | {
| |
| 11 | COORD coord; | |
| 12 | coord.X = x; | |
| 13 | coord.Y = y; | |
| 14 | SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord); | |
| 15 | } | |
| 16 | void SetColor(short Color) | |
| 17 | {
| |
| 18 | HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE); // oppure system("COLOR E9");
| |
| 19 | SetConsoleTextAttribute(hCon,Color); | |
| 20 | } | |
| 21 | ||
| 22 | void sfondo(){
| |
| 23 | system("color 70");
| |
| 24 | }//sfondo | |
| 25 | ||
| 26 | ||
| 27 | /*Funzioni di controllo*/ | |
| 28 | //------------------------------------------------------------------------------ | |
| 29 | bool uscito(int a[], int b){
| |
| 30 | for(int i=1;i<=90;i++) | |
| 31 | if(a[i]==b) | |
| 32 | return true; | |
| 33 | return false; | |
| 34 | }//uscito | |
| 35 | ||
| 36 | bool isNeg(int a[]){
| |
| 37 | for(int i=1;i<=90;i++) | |
| 38 | if(a<0) | |
| 39 | return true; | |
| 40 | return false; | |
| 41 | }//isNeg | |
| 42 | ||
| 43 | //------------------------------------------------------------------------------ | |
| 44 | - | h2=rand()%((h-10))+1; |
| 44 | + | |
| 45 | //------------------------------------------------------------------------------ | |
| 46 | void cartella(int y[]){
| |
| 47 | srand(time(NULL)); | |
| 48 | int h,h2; | |
| 49 | for(int i=1;i<=10;i++){
| |
| 50 | h=rand()%(90)+1; | |
| 51 | h2=rand()%((h-7))+1; | |
| 52 | if(!(uscito(y,h2))&&!(isNeg(y))) | |
| 53 | y[i]=h2; | |
| 54 | else | |
| 55 | i--; | |
| 56 | }//for | |
| 57 | - | c2=rand()%((c-5))+1; |
| 57 | + | |
| 58 | ||
| 59 | void cartella1(int z[]){
| |
| 60 | srand(time(NULL)); | |
| 61 | int c,c2; | |
| 62 | for(int i=1;i<=10;i++){
| |
| 63 | c=rand()%(90)+1; | |
| 64 | c2=rand()%((c-3))+1; | |
| 65 | if(!(uscito(z,c2))&&!(isNeg(z))) | |
| 66 | z[i]=c2; | |
| 67 | else | |
| 68 | i--; | |
| 69 | }//for | |
| 70 | }//cartella1 | |
| 71 | ||
| 72 | void tombola(int a[]){
| |
| 73 | srand(time(NULL)); | |
| 74 | int b; | |
| 75 | for(int i=1;i<=90;i++){
| |
| 76 | b=rand()%(90-1+1)+1; | |
| 77 | if(!(uscito(a,b))) | |
| 78 | a[i]=b; | |
| 79 | else | |
| 80 | i--; | |
| 81 | }//for | |
| 82 | }//tombola | |
| 83 | //------------------------------------------------------------------------------ | |
| 84 | /*Stampa cartelle e tombola*/ | |
| 85 | //------------------------------------------------------------------------------ | |
| 86 | void stcart(int y[]){
| |
| 87 | cout<<"\n\nLa tua cartella e`:\n\n"; | |
| 88 | for(int i=1;i<=10;i++) | |
| 89 | cout<<y[i]<<"\t"; | |
| 90 | }//stcart | |
| 91 | ||
| 92 | void stcart1(int z[]){
| |
| 93 | cout<<"\n\nLa cartella del computer e`:\n\n"; | |
| 94 | for(int i=1;i<=10;i++) | |
| 95 | cout<<z[i]<<"\t"; | |
| 96 | }//stcart | |
| 97 | ||
| 98 | ||
| 99 | int estraz(int a[], int y[], int z[]/*, int *ambo, int *terno, int *cinq*/){
| |
| 100 | int c=0; | |
| 101 | int t=0; | |
| 102 | - | if(t==10) |
| 102 | + | |
| 103 | for(int i=1;i<=90;i++){
| |
| 104 | Sleep(80); | |
| 105 | cout<<a[i]<<"\t"; | |
| 106 | for(int j=1;j<=10;j++){
| |
| 107 | if(a[i]==y[j]){
| |
| 108 | t++; | |
| 109 | if(t==13) | |
| 110 | return t; | |
| 111 | }//if | |
| 112 | if(a[i]==z[j]){
| |
| 113 | c--; | |
| 114 | if(c==-10) | |
| 115 | - | if(win==10) |
| 115 | + | |
| 116 | - | cout<<"\n\nHai vinto!!!"; |
| 116 | + | |
| 117 | if(t==2){
| |
| 118 | - | cout<<"\n\nHa vinto il computer :(";
|
| 118 | + | cout<<"\nhai fatto ambo! "; |
| 119 | getchar(); | |
| 120 | t++; | |
| 121 | }//if | |
| 122 | if(t==4){
| |
| 123 | cout<<"\nhai fatto terno! "; | |
| 124 | getchar(); | |
| 125 | t++; | |
| 126 | }//if | |
| 127 | if(t==6){
| |
| 128 | cout<<"\nhai fatto cinquina! "; | |
| 129 | getchar(); | |
| 130 | t++; | |
| 131 | }//if | |
| 132 | }//for-j | |
| 133 | }//for-i | |
| 134 | }//stampa | |
| 135 | ||
| 136 | void vinto(int win){
| |
| 137 | if(win==13) | |
| 138 | cout<<"\n\n\t\t\tHai vinto :D"; | |
| 139 | else | |
| 140 | cout<<"\n\n\t\t\tHa vinto il computer :(";
| |
| 141 | }//vinto | |
| 142 | //------------------------------------------------------------------------------ | |
| 143 | ||
| 144 | ||
| 145 | int main(){
| |
| 146 | int a[N],y[N],z[N]; | |
| 147 | sfondo(); | |
| 148 | cartella(y); | |
| 149 | stcart(y); | |
| 150 | cartella1(z); | |
| 151 | stcart1(z); | |
| 152 | tombola(a); | |
| 153 | vinto(estraz(a,y,z)); | |
| 154 | fflush(stdin); | |
| 155 | getchar(); | |
| 156 | return 0; | |
| 157 | }//main |