Urgent, please read

Discussion in 'Programming General' started by diabl0, Feb 1, 2011.

Urgent, please read
  1. Unread #1 - Feb 1, 2011 at 10:04 AM
  2. diabl0
    Joined:
    Jul 25, 2008
    Posts:
    902
    Referrals:
    0
    Sythe Gold:
    0

    diabl0 Apprentice
    Banned

    Urgent, please read

    Okay, I am in class, I need help with my code. The code is a Word jumble.

    Okay what I have is

    Code:
    // Tyler sinks
    // Programming 1
    // Barry Fawthrop
    // January 29, 2011
    
    // This is a word jumble
    // You are given 5 words scrambled up!
    
    #include "stdafx.h"
    #include <iostream>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    
    using namespace std;
    
    // Words and their hints!
    int _tmain(int argc, _TCHAR* argv[])
    {
    const int SIZE = 25; // the words and the arry they are in
    string WORD[SIZE] = {"word" , "nice" , "walk" , "open" , "door", 
    "carry" , "blue" , "green" , "black" ,
    "string" , "yellow" , "pink" , "gray" ,
    "duck" , "bick" , "candy" ,"truck" , 
    "yawn" , "lawn" , "hunt" , "fish" , 
    "soda" , "drink" , "rink" , "snowboard"};
    int counter;
    
    srand(time(0));
    // The counter so no more than 5
    for (counter = 0; counter < 5; counter++){
    int select = (rand() % SIZE);
    string randWord =WORD[select];
    string jumble = randWord;
    int length = jumble.size();
    // Randomizing!
    for (int i = 0; i < length; ++i)
    {
    int index1 = (rand() % length);
    int index2 = (rand() % length);
    char temp = jumble[index1];
    jumble[index1] = jumble[index2];
    jumble[index2] = temp ;
    }
    
    int wordLength = WORD[select].size();
    if (wordLength > 7)
    cout << jumble << "\n";
    else
    cout << jumble << "\n";
    
    
    }
    
    return 0;
    }
    
    What I need to do from this code is make it to where you can guess what the words are, but you only have 4 chances to guess..
     
< Hacker: Thanks for the gold bro. | Java suggestions >

Users viewing this thread
1 guest


 
 
Adblock breaks this site