#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
int lucky[3];
srand(time(0));
const int max = sizeof(lucky)/sizeof(int);
for(int i = max-1; 0 <= i; i --){
lucky[i] = (int)(rand() % 10);
}
int guess[max];
cout << "Guess " << max << " numbers: ";
for(int i = max-1; 0 <= i; i --){
cin >> guess[i];
}
int credits = 0;
cout << endl << "Your guess: ";
for(int i = max-1; 0 <= i; i --){
cout << guess[i];
if(i) cout << ", ";
if(guess[i] == lucky[i]) credits ++;
}
cout << endl << "Lucky numbers: ";
for(int i = max-1; 0 <= i; i --){
cout << lucky[i];
if(i) cout << ", ";
}
cout << endl << "You won credits: " << credits << endl;
return 0;
}
Download
Comments
Post a Comment