Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdlib.h>
- #include<conio.h>
- #include<iostream>
- #include<time.h>
- using namespace std;
- int suma = 0 , user;
- bool win = false;
- int generate_random() {
- int n = 10;
- srand(time(NULL));
- int g = rand() % n;
- return g;
- }
- int main() {
- while (suma <= 100) {
- int calculator = generate_random();
- while (suma + calculator <= 89) {
- suma = suma + calculator;
- cout << calculator << "\n";
- break;
- }
- if (suma >= 90) {
- calculator = 100 - suma;
- cout << calculator << "\n";
- suma = suma + calculator;
- }
- if (suma == 100) {
- win = false;
- cout << "Ai pierdut!";
- break;
- }
- cin >> user;
- while (suma + user > 100) {
- cin >> user;
- }
- suma = suma + user;
- cout << "Suma: " << suma << "\n";
- if (suma == 100) {
- win = true;
- cout << "Ai castigat!";
- break;
- }
- }
- _getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement