Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <time.h>
- #include <windows.h>
- #include <string>
- #include <stdio.h>
- #include <conio.h>
- #include <math.h>
- using namespace std;
- void loosemusic()
- {
- Beep (131,500);
- Beep (123,500);
- Beep (110,500);
- Beep (104,1000);
- }
- void winmusic()
- {
- int gama[6];
- gama[0]=262;
- gama[1]=294;
- gama[2]=330;
- gama[3]=349;
- gama[4]=392;
- gama[5]=440;
- gama[6]=494;
- Beep(gama[0],200);
- Beep(gama[0],200);
- Beep(gama[2],200);
- Beep(gama[4],400);
- Beep(gama[2],200);
- Beep(gama[4],800);
- }
- int main() {
- int i,E=1,l=1,pot,w1=0,w2=0,wo1=0,wo2=0,m,u,length,maxlength,note;
- float rounds;
- unsigned long long n,n1,n2,R,q;
- string name1;
- string name2;
- for(E; E<2; E)
- {
- cout << "Press 1 for player Vs Pc mode, press 2 for two players mode, press 3 to learn how does Collatz Conjecture work:"<<endl<<endl<<endl;
- cin >>m;
- if (m==3)
- {
- cout<<"Program takes your number then, checks is it even or odd. If it's even it divides it by 2, if it is odd it multiply it by 3 and add 1. It does that until it reaches 1."<<endl<<endl<<endl;;
- cout<<"For example, you chose number 5."<<endl;
- cout<<"5-odd so 5*3+1=16 "<<endl;
- cout<<"16-even so 16/2=8"<<endl;
- cout<<"8-even so 8/2=4"<<endl;
- cout<<"4-even so 4/2=2"<<endl;
- cout<<"2-even so 2/2=1"<<endl<<endl;
- cout<<"the more ''steps'' until it reach 1 the bigger score you'll have"<<endl<<endl<<endl;
- cout << "Press 1 for player Vs Pc mode, press 2 for two players mode, press 3 to learn how does Collatz Conjecture work:"<<endl;
- cin >>m;
- }
- if (m==1){
- // for(E; E<2; E)
- // {
- w1=0;
- w2=0;
- cout << "Enter any integer between 0 and 18*10^18 (18 and 18 zeros) "<<endl;
- cin >> n;
- while (n > 1)
- {
- if ( n%2 == 0)
- {
- n=n/2;
- cout << n << endl;
- w1=w1+1;
- Sleep(20);
- }
- else {
- n=3*n+1;
- cout << n << endl;
- w1=w1+1;
- Sleep(20);
- }
- }
- cout << "You scored ";
- cout << w1;
- cout << " points!"<<endl;
- cout << "Pc is picking integer..."<< endl;
- Sleep(3000);
- srand(time(NULL));
- pot =rand()%4+1;
- u=rand()%30+1;
- q=pow(u, pot);
- R=((rand()%100+1)*q*(rand()%50+1));
- cout << "He picked:"<< endl;
- cout << R << endl;
- Sleep(3000);
- while (R > 1)
- {
- if ( R%2 == 0) {
- R=R/2;
- cout << R << endl;
- w2=w2+1;
- Sleep(20);
- }
- else {
- R=3*R+1;
- cout << R << endl;
- w2=w2+1;
- Sleep(20);
- }
- }
- cout << "Computer scored " ;
- cout << w2;
- cout <<" points!"<<endl;
- if(w1<w2)
- {
- cout << "YOU LOST..."<<endl<<endl;
- loosemusic();
- }
- else
- {
- cout << "YOU WIN!!! :D"<<endl<<endl;
- winmusic();
- }
- cout<<"Press 1 to play again, press 2 to exit:"<<endl;
- cin>> E;
- // }
- }
- if (m==2)
- {
- cout<< "Enter maximum number of rounds you want to play:"<< endl;
- cin>>rounds;
- cout << "Enter your name Player 1:" << endl;
- cin>> name1;
- cout << "Enter your name Player 2:" << endl;
- cin>> name2;
- for(int dumb=0; dumb<1; dumb)
- {
- cout <<"Enter maximum numbers of digits for your numbers (cannot be bigger than 18)"<<endl;
- cin>>maxlength;
- if(maxlength<19 && maxlength>0)
- dumb++;
- else
- cout<<"Learn to read, it's useful ability ;)"<<endl;
- }
- cout << "LETS GET READY TO RUMBLE!!" << endl<<endl;
- l=1;
- wo1=0;
- wo2=0;
- Sleep(3000);
- for(l; l<=rounds+1; l){
- if(wo1<=rounds/2 && wo2<=rounds/2)
- {
- w1=0;
- w2=0;
- for (int dumb=0; dumb<1; dumb){
- cout << "Enter any integer with max. ";
- cout<< maxlength;
- cout << " digits ";
- cout << name1;
- cout<< ":"<<endl;
- cin >> n1;
- n=n1;
- length = 1;
- while ( n1 /= 10 )
- length++;
- if(length<=maxlength)
- {
- dumb++;
- }
- else
- {
- cout<<"Try to read... It won't hurt you ;)"<<endl<<endl;
- Sleep(1000);
- }
- }
- while (n > 1)
- {
- if ( n%2 == 0)
- {
- n=n/2;
- cout << n << endl;
- w1=w1+1;
- Sleep(20);
- }
- else {
- n=3*n+1;
- cout << n << endl;
- w1=w1+1;
- Sleep(20);
- }
- }
- cout << name1;
- cout << " Scored ";
- cout << w1;
- cout << " points!"<<endl<<endl;
- for (int dumb=0; dumb<1; dumb){
- cout << "Enter any integer with max. ";
- cout<< maxlength;
- cout << " digits ";
- cout << name2;
- cout<< ":"<<endl;
- cin >> n1;
- n2=n1;
- length = 1;
- while ( n1 /= 10 )
- length++;
- if(length<=maxlength)
- {
- dumb++;
- }
- else
- {
- cout<<"Try to read... It won't hurt you ;)"<<endl<<endl;
- Sleep(1000);
- }
- }
- while (n2 > 1)
- {
- if ( n2%2 == 0)
- {
- n2=n2/2;
- cout << n2 << endl;
- w2=w2+1;
- Sleep(20);
- }
- else {
- n2=3*n2+1;
- cout << n2 << endl;
- w2=w2+1;
- Sleep(20);
- }
- }
- cout << name2;
- cout << " Scored ";
- cout << w2;
- cout << " points!"<<endl<<endl;
- Sleep (2000);
- if(w1!=w2)
- {
- if(w1>w2)
- {
- cout<<name1;
- wo1++;
- }
- else
- {
- cout<<name2;
- wo2++;
- }
- cout<<" is the winner of the ";
- cout<<l;
- if(l==1)
- cout<< "st ";
- if(l==2)
- cout<< "nd ";
- if (l==3)
- cout<< "rd ";
- if (l>3)
- cout<< "th ";
- cout<<"round!"<<endl<<endl;
- l++;
- }
- else
- {
- cout<<"It's a draw!"<<endl;
- }
- Sleep(1000);
- cout<<name1;
- cout<<"'s score: ";
- cout<<wo1<<endl<<endl;
- cout<<name2;
- cout<<"'s score: ";
- cout<<wo2<<endl<<endl;
- }
- else
- {
- if(wo1>wo2)
- {
- cout<<name1;
- cout<< " IS THE WINNER OF THE GAME!!"<<endl<<endl;
- winmusic();
- }
- else
- {
- cout<<name2;
- cout<< " IS THE WINNER OF THE GAME!!"<<endl<<endl;
- winmusic();
- }
- cout<<"Do you want to play again? Press 1 if you want to play, press 2 if you want to exit:"<<endl<<endl;
- cin>>E;
- l++;
- /*
- cout<< name1;
- cout<<" ";
- cout<<wo1;
- cout<<":";
- cout<<wo2;
- cout<<" ";
- cout<< name2 <<endl;
- */
- }
- if(wo1*2==rounds && wo2*2==rounds )
- {
- cout<<"You've reached the limit of rounds... It' s a DRAW!!"<<endl;
- cout<<"Do you want to play again? Press 1 if you want to play, press 2 if you want to exit:"<<endl<<endl;
- cin>>E;
- l++;
- }
- }
- }
- }
- cout<<"Dziaba"<<endl<<endl;
- Sleep(500);
- cout<<"Dziaba"<<endl<<endl;
- Sleep(500);
- cout<<"Dziaba"<<endl<<endl;
- Sleep(500);
- if(E==1){
- getch();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement