snakesnladders.cpp - /= Name snakes and ladders Author...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
//============================================================================ // Name : snakes and ladders // Author : Darshan Dharmik //Roll No :SCSB 127 // Copyright : Your copyright notice //============================================================================ #include <iostream> #include <ctime> #include <cstdlib> using namespace std; class node{ public: int data; node*next; node*prev; }; class dllist{ node*start; public: dllist(){start=NULL;} void create(int value) { node*temp,*s; temp=new node; temp->data=value; temp->next=NULL; if(start==NULL) { temp->prev=NULL; start=temp; } else { s=start; while(s->next!=NULL) s=s->next; temp->prev=s; s->next=temp; } } void display() { node*m; m=start; if(m==NULL) { cout<<"The list is empty"<<endl; } else { while(m!=NULL) { cout<<m->data<<endl; m=m->next; } } } int play_dice() { int r; srand(time(NULL)); r=rand()%6+1;
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
return r; } node*forward_shift(int value,node*v) { int i; for(i=1;i<=value;i++) v=v->next; return v; } int new_score(int score) { int fscore; switch(score) { case 7: fscore=12; break; case 8: fscore=13; break; case 16: fscore=29; break; case 19: fscore=27; break; case 9: fscore=4; break; case 17: fscore=2; break; case 24: fscore=20; break; case 26: fscore=1; break; default: fscore=score; break; } return fscore; } int play() { int score1=1,score2=1,c,new_s,dice;
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern