#include <iostream> #include <string> #include <ctime> #include <cstdlib> #include <time.h> using namespace std; int Rselect(); void Obstacle_description (int Ran_num); int repeat1 (int& dc, int& lifepoint, int& time); void Lifepoints(int& lifepoint); int main() { int i=0; do{ int lifepoint=10; srand(time(0)); string choice; i++; cout<<"welcome to pitfall adventure! can you overcome ten dangerous jungle obstacle in 30 minutes? Let's start and find out!\n"; int x=rand()%6+1; int dc=3*x; int time=30; int Ran_num; Ran_num=Rselect(); cout<<"Time="<<time<<" minutes\n"; Obstacle_description (Ran_num); //function obstacle if(dc<=7) cout<<"it looks easy"<<". "; else if (dc>=14) cout<<"it looks hard"<<". "; cout<<"Do you <rush> or <study> it and then try it?"; cin>>choice; if(choice=="rush") {time-=2; dc+=2; repeat1 (dc,lifepoint,time); cout<<time; } else if(choice =="study") {time-=5; dc-=5; repeat1 (dc,lifepoint,time); cout<<time; } cout<<"better next time"; }while(time>0 && i < 10); cout<<"win"; return 0; } // slect random number between 0 to 10 that is never smae number to show up int Rselect() { int i=1,Pnum=-1, Nnum=-1; for(i=1; i<=10; i++) {Nnum = rand()%10+1; while(Nnum==Pnum) Nnum = rand()%10+1;} Pnum=Nnum; return Nnum; } //fuction that dc comepared with number(ramdomly variable b/w 1 and 20) int repeat1 (int& dc, int& lifepoint, int&time) { string choose; int w; do { cout<<"fail!"; Lifepoints(lifepoint); cout<<"Do you <rush> or <study> it and then try it?"; cin>>choose; if(choose=="rush") {time-=2; dc+=2; return time;} else if(choose=="study") {time-=5; dc-=5; cout<<time;} w = rand()%20+1; }while (w<dc); cout<<"success!"; return Rselect(); } //function of obstacle void Obstacle_description (int Ran_num) { string obstacle; if (Ran_num==1) {obstacle = "you encounter a nasty looking pit. it's not very deep, but it has wooden spikes at the bottom. you'll have to jump it to continue."; cout<<"\n"<<"Obstacle: "<<obstacle;} else if (Ran_num==2) {obstacle = "Before you is a wide river. is it deep or not? hard to tell! you'll have to swim it."; cout<<"Obstacle: "<<obstacle<<"\n";} else if (Ran_num==3) {obstacle = "There is big a hedge. you'll have to climb over the hedge."; cout<<"Obstacle: "<<obstacle<<"\n";} else if (Ran_num==4) {obstacle = "you can see a big tree there. you'll have to climb the big tree."; cout<<"Obstacle: "<<obstacle<<"\n";} else if (Ran_num==5) {obstacle = "It looks like a narrow pond. you'll have to jump"; cout<<"Obstacle: "<<obstacle<<"\n";} else if (Ran_num==6) {obstacle = "There is a small gorge you'll have to jump"; cout<<"Obstacle: "<<obstacle<<"\n";} else if (Ran_num==7) {obstacle = "you can see a Tiger you'll have to avoid the tiger"; cout<<"Obstacle: "<<obstacle<<"\n";} else if (Ran_num==8) {obstacle = "There is a mud. you'll have to jump"; cout<<"Obstacle: "<<obstacle<<"\n";} else if (Ran_num==9) {obstacle = "It looks like a lion. you'll have to avoid the lion"; cout<<"Obstacle: "<<obstacle<<"\n";} else if (Ran_num==10) {obstacle = "There is Myrsinaleaf oak in front of you. you'll have to jump the that"; cout<<"Obstacle: "<<obstacle<<"\n";} return ; } //function of life point void Lifepoints(int& lifepoint) { int z= rand()%4; if(lifepoint>0) { if (z==0) { cout<<"life is "<<" minor scratches,no harm"; lifepoint=lifepoint-z;} else if (z==1) {cout<<"life is "<<" minor damage"; lifepoint=lifepoint-z;} else if (z==2) {cout<<"life is "<<" moderate damage"; lifepoint=lifepoint-z;} else if (z==3) {cout<<"life is "<<"major damage"; lifepoint=lifepoint-z;} return; } else if (lifepoint<=0) { cout<<"game end\n"; return; } }
Standard input is empty
prog.cpp:52:15: warning: missing terminating " character [enabled by default] cout<<"welcome to pitfall adventure! can you overcome ten ^ prog.cpp:52:9: error: missing terminating " character cout<<"welcome to pitfall adventure! can you overcome ten ^ prog.cpp:53:45: warning: missing terminating ' character [enabled by default] dangerous jungle obstacle in 30 minutes? Let's start and find out!\n"; ^ prog.cpp:53:1: error: missing terminating ' character dangerous jungle obstacle in 30 minutes? Let's start and find out!\n"; ^ prog.cpp:225:37: warning: missing terminating " character [enabled by default] if (Ran_num==1) {obstacle = "you encounter a nasty looking ^ prog.cpp:225:9: error: missing terminating " character if (Ran_num==1) {obstacle = "you encounter a nasty looking ^ prog.cpp:226:8: warning: missing terminating ' character [enabled by default] pit. it's not very deep, but it has wooden spikes at the bottom. ^ prog.cpp:226:1: error: missing terminating ' character pit. it's not very deep, but it has wooden spikes at the bottom. ^ prog.cpp:227:4: warning: missing terminating ' character [enabled by default] you'll have to jump it to continue."; ^ prog.cpp:227:1: error: missing terminating ' character you'll have to jump it to continue."; ^ prog.cpp:233:42: warning: missing terminating " character [enabled by default] else if (Ran_num==2) {obstacle = "Before you is a wide river. ^ prog.cpp:233:9: error: missing terminating " character else if (Ran_num==2) {obstacle = "Before you is a wide river. ^ prog.cpp:234:37: warning: missing terminating ' character [enabled by default] is it deep or not? hard to tell! you'll have to swim it."; ^ prog.cpp:234:1: error: missing terminating ' character is it deep or not? hard to tell! you'll have to swim it."; ^ prog.cpp:239:42: warning: missing terminating " character [enabled by default] else if (Ran_num==3) {obstacle = "There is big a hedge. you'll ^ prog.cpp:239:9: error: missing terminating " character else if (Ran_num==3) {obstacle = "There is big a hedge. you'll ^ prog.cpp:240:30: warning: missing terminating " character [enabled by default] have to climb over the hedge."; ^ prog.cpp:240:1: error: missing terminating " character have to climb over the hedge."; ^ prog.cpp:246:42: warning: missing terminating " character [enabled by default] else if (Ran_num==4) {obstacle = "you can see a big tree ^ prog.cpp:246:9: error: missing terminating " character else if (Ran_num==4) {obstacle = "you can see a big tree ^ prog.cpp:247:11: warning: missing terminating ' character [enabled by default] there. you'll have to climb the big tree."; ^ prog.cpp:247:1: error: missing terminating ' character there. you'll have to climb the big tree."; ^ prog.cpp:253:42: warning: missing terminating " character [enabled by default] else if (Ran_num==5) {obstacle = "It looks like a narrow pond. ^ prog.cpp:253:9: error: missing terminating " character else if (Ran_num==5) {obstacle = "It looks like a narrow pond. ^ prog.cpp:254:4: warning: missing terminating ' character [enabled by default] you'll have to jump"; ^ prog.cpp:254:1: error: missing terminating ' character you'll have to jump"; ^ prog.cpp:260:42: warning: missing terminating " character [enabled by default] else if (Ran_num==6) {obstacle = "There is a small gorge ^ prog.cpp:260:9: error: missing terminating " character else if (Ran_num==6) {obstacle = "There is a small gorge ^ prog.cpp:261:4: warning: missing terminating ' character [enabled by default] you'll have to jump"; ^ prog.cpp:261:1: error: missing terminating ' character you'll have to jump"; ^ prog.cpp:267:42: warning: missing terminating " character [enabled by default] else if (Ran_num==7) {obstacle = "you can see a Tiger you'll ^ prog.cpp:267:9: error: missing terminating " character else if (Ran_num==7) {obstacle = "you can see a Tiger you'll ^ prog.cpp:268:24: warning: missing terminating " character [enabled by default] have to avoid the tiger"; ^ prog.cpp:268:1: error: missing terminating " character have to avoid the tiger"; ^ prog.cpp:280:42: warning: missing terminating " character [enabled by default] else if (Ran_num==9) {obstacle = "It looks like a lion. you'll ^ prog.cpp:280:9: error: missing terminating " character else if (Ran_num==9) {obstacle = "It looks like a lion. you'll ^ prog.cpp:281:23: warning: missing terminating " character [enabled by default] have to avoid the lion"; ^ prog.cpp:281:1: error: missing terminating " character have to avoid the lion"; ^ prog.cpp:287:43: warning: missing terminating " character [enabled by default] else if (Ran_num==10) {obstacle = "There is Myrsinaleaf oak in ^ prog.cpp:287:9: error: missing terminating " character else if (Ran_num==10) {obstacle = "There is Myrsinaleaf oak in ^ prog.cpp:288:18: warning: missing terminating ' character [enabled by default] front of you. you'll have to jump the that"; cout<<"Obstacle: ^ prog.cpp:288:1: error: missing terminating ' character front of you. you'll have to jump the that"; cout<<"Obstacle: ^ prog.cpp:289:1: error: stray ‘\’ in program "<<obstacle<<"\n";} ^ prog.cpp:289:17: warning: missing terminating " character [enabled by default] "<<obstacle<<"\n";} ^ prog.cpp:289:1: error: missing terminating " character "<<obstacle<<"\n";} ^ prog.cpp: In function ‘int main()’: prog.cpp:53:1: error: ‘dangerous’ was not declared in this scope dangerous jungle obstacle in 30 minutes? Let's start and find out!\n"; ^ prog.cpp:53:11: error: expected ‘;’ before ‘jungle’ dangerous jungle obstacle in 30 minutes? Let's start and find out!\n"; ^ prog.cpp:57:18: error: ‘x’ was not declared in this scope int dc=3*x; ^ prog.cpp: In function ‘void Obstacle_description(int)’: prog.cpp:226:1: error: ‘pit’ was not declared in this scope pit. it's not very deep, but it has wooden spikes at the bottom. ^ prog.cpp:227:1: error: expected ‘;’ before ‘you’ you'll have to jump it to continue."; ^ prog.cpp:234:1: error: ‘is’ was not declared in this scope is it deep or not? hard to tell! you'll have to swim it."; ^ prog.cpp:234:4: error: expected ‘;’ before ‘it’ is it deep or not? hard to tell! you'll have to swim it."; ^ prog.cpp:240:1: error: ‘have’ was not declared in this scope have to climb over the hedge."; ^ prog.cpp:240:6: error: expected ‘;’ before ‘to’ have to climb over the hedge."; ^ prog.cpp:247:1: error: ‘there’ was not declared in this scope there. you'll have to climb the big tree."; ^ prog.cpp:249:13: error: expected ‘;’ before ‘cout’ cout<<"Obstacle: "<<obstacle<<"\n";} ^ prog.cpp:254:1: error: ‘you’ was not declared in this scope you'll have to jump"; ^ prog.cpp:256:13: error: expected ‘;’ before ‘cout’ cout<<"Obstacle: "<<obstacle<<"\n";} ^ prog.cpp:261:1: error: ‘you’ was not declared in this scope you'll have to jump"; ^ prog.cpp:263:13: error: expected ‘;’ before ‘cout’ cout<<"Obstacle: "<<obstacle<<"\n";} ^ prog.cpp:268:1: error: ‘have’ was not declared in this scope have to avoid the tiger"; ^ prog.cpp:268:6: error: expected ‘;’ before ‘to’ have to avoid the tiger"; ^ prog.cpp:281:1: error: ‘have’ was not declared in this scope have to avoid the lion"; ^ prog.cpp:281:6: error: expected ‘;’ before ‘to’ have to avoid the lion"; ^ prog.cpp:288:1: error: ‘front’ was not declared in this scope front of you. you'll have to jump the that"; cout<<"Obstacle: ^ prog.cpp:288:7: error: expected ‘;’ before ‘of’ front of you. you'll have to jump the that"; cout<<"Obstacle: ^ prog.cpp:311:5: error: a function-definition is not allowed here before ‘{’ token { int z= rand()%4; ^ prog.cpp:347:5: error: expected ‘}’ at end of input } ^
Standard output is empty