Welcome
Welcome to the forums of AntiRTFM's Absolute N00b Spoonfeed C++ Tutorials!

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. Registration is fast, simple, and absolutely free, so please, <a href="/profile.php?mode=register">join our community today</a>!

Console - Jumble Words

Finished making your own program (thats not part of the practicing forums) ? Show it off here

Console - Jumble Words

Postby cyberspy on Sun Sep 13, 2009 4:29 am

Although I spent long time on this, game, but it may contain some bugs, which i ve left for you,
words, and there respective hints on lines 10, 11 and 12, are editable, you can write any string you want.

Thanks for Using.



Code: Select all
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <string>
using namespace std;
int randinit();
string jumble(string);
int main()
{
   const string Word[3][2]={
      {"Undefined","Something which is not defined"},
      {"Explaination","Definition of undefinable"},
      {"Hello","First word you say on your phone"}
   };
   const int rand_No = randinit();
    unsigned short row = rand_No%3, column = rand_No%2;
   
   string the_word=Word[row][0];
   string the_hint=Word[row][1];
   string jumbled;
   string answer;
   jumbled = jumble(the_word);
   cout<<"\t\t\tWelcome To Jumble Word\n\n\n\n\n\n\n\n";
   cout<<"Here's your word : \n"<<jumbled;
Jump:
   cout<<"\t";
   cin>>answer;
    if(answer==the_word)
      cout<<"\nCorrect!!!\n";
   else
   {
      cout<<"\nWrong\n";
      cout<<"Hint?('y'/'n')";
      char conti;
      cin>>conti;
      if (conti == 'y')
      {
         cout<<the_hint;
         goto Jump;
      }
      else
         cout<<"\nThen get the hell outa here!!!!!\n";
   }
        cout<<"Written By CyberSpy aka TheFutureOfEminem\n";
   
   system ("pause");
   return 0;
}
int randinit()
{
   srand(time(0));
   return rand();
}

string jumble(string jumble)
{
   int size=jumble.size();
   
   for (int x=0; x<size; x++)
   {
   int index1 = rand() % size;
   int index2 = rand() % size;
   char temp = jumble[index1];
   jumble[index1]=jumble[index2];
    jumble[index2]=temp;
   }
      return jumble;
}
cyberspy
 
Posts: 12
Joined: Sun Sep 13, 2009 4:14 am

Return to Full programs

Who is online

Users browsing this forum: No registered users and 0 guests