Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <cstdlib>
- #include <iomanip>
- using namespace std;
- int p, bank = 5;
- void meniu();
- void bankas();
- void loterija();
- void uzkrauti();
- void issaugoti();
- ifstream fd("duom.txt");
- ofstream fr("duom.txt");
- int main()
- {
- uzkrauti();
- meniu();
- return 0;
- }
- void uzkrauti(){
- fd >> bank;
- }
- void issaugoti(){
- fr << bank;
- }
- void bankas(){
- cout << endl << "Banko saskaitos balansas:" << setw(3) << bank << endl;
- meniu();
- }
- void loterija(){
- int lot;
- int skaicius = rand() % 10 + 1;
- if(bank != 0){
- cout << "Loterijos tikslas: Turite atspeti, ar skaicius didesnis nei 5 ar mazesnis" << endl;
- cout << "Pasirinkite:" << endl;
- cout << "1. Didesnis nei 5" << endl;
- cout << "2. Mazesnis nei 5" << endl;
- cin >> lot;
- if(lot == 1){
- if(5 < skaicius){
- cout << "Laimejote! Padvigubinote savo banka. Skaicius = " << skaicius << endl;
- bank*=2;
- }
- else{
- cout << "Pralaimejote! Jusu bankas sumazejo per puse. Skaicius = " << skaicius << endl;
- bank/=2;
- }
- meniu();
- }
- if(lot == 2){
- if(5 > skaicius){
- cout << "Laimejote! Padvigubinote savo banka. Skaicius = " << skaicius << endl;
- bank*=2;
- }
- else{
- cout << "Pralaimejote! Jusu bankas sumazejo per puse. Skaicius = " << skaicius << endl;
- bank/=2;
- }
- meniu();
- }
- else meniu();
- }
- else cout << "Nebeturite balanse kreditu ! " << endl; meniu();
- }
- void meniu(){
- cout << "Pasirinkite:" << endl;
- cout << "1. Isvalyti ekrana" << endl;
- cout << "2. Bankas" << endl;
- cout << "3. Loterija" << endl;
- cout << "Noredami iseiti is meniu - iveskite 0" << endl;
- cin >> p;
- if(p == 0) {issaugoti(); exit(0);}
- if(p == 1) {for(int i = 0; i < 100; i++) cout << endl; meniu();}
- if(p == 2) bankas();
- if(p == 3) loterija();
- else{ cout << "Klaidingai ivestas meniu punktas" << endl; meniu();}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement