data structers mini project

hello everyone
our class have been asked to make a small application using c++ through data structure
it need not have visual effects
plzzz help me out wid some topics and codes
P.S topic is more important
What are you stuck on? What code have you written so far?
help me out wid some topics and codes

You could make a binary tree (or a general tree), or a hash table, or a stack or queue. As for what to do with them, I think you can think of that.

Off topic:
Am I the only one who sees all these reported posts?
http://snag.gy/FB478.jpg
this is what i had submitted which got rejected

#include <iostream.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>

const int MAXLENGTH=80;
const int MAX_TRIES=5;
const int MAXROW=7;

int letterFill (char, char[], char[]);
void initUnknown (char[], char[]);

int main ()
{
char unknown [MAXLENGTH];
char letter;
int num_of_wrong_guesses=0;
char word[MAXLENGTH];
char words[][MAXLENGTH] =
{
"india",
"pakistan",
"nepal",
"malaysia",
"philippines",
"australia",
"iran",
"ethiopia",
"oman",
"indonesia"
};

//choose and copy a word from array of words randomly
randomize();
int n=random(10);
strcpy(word,words[n]);

// Initialize the secret word with the * character.
initUnknown(word, unknown);

// welcome the user
cout << "\n\nWelcome to hangman...Guess a country Name";
cout << "\n\nEach letter is represented by a star.";
cout << "\n\nYou have to type only one letter in one try";
cout << "\n\nYou have " << MAX_TRIES << " tries to try and guess the word.";
cout << "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";

// Loop until the guesses are used up
while (num_of_wrong_guesses < MAX_TRIES)
{
cout << "\n\n" << unknown;
cout << "\n\nGuess a letter: ";
cin >> letter;
// Fill secret word with letter if the guess is correct,
// otherwise increment the number of wrong guesses.
if (letterFill(letter, word, unknown)==0)
{
cout << endl << "Whoops! That letter isn't in there!" << endl;
num_of_wrong_guesses++;
}
else
{
cout << endl << "You found a letter! Isn't that exciting!" << endl;
}
// Tell user how many guesses has left.
cout << "You have " << MAX_TRIES - num_of_wrong_guesses;
cout << " guesses left." << endl;
// Check if they guessed the word.
if (strcmp(word, unknown) == 0)
{
cout << word << endl;
cout << "Yeah! You got it!";
break;
}
}
if(num_of_wrong_guesses == MAX_TRIES)
{
cout << "\nSorry, you lose...you've been hanged." << endl;
cout << "The word was : " << word << endl;
}
getch();
return 0;
}

/* Take a one character guess and the secret word, and fill in the
unfinished guessword. Returns number of characters matched.
Also, returns zero if the character is already guessed. */

int letterFill (char guess, char secretword[], char guessword[])
{
int i;
int matches=0;
for (i = 0; secretword[i]!='\0'; i++)
{
// Did we already match this letter in a previous guess?
if (guess == guessword[i])
return 0;
// Is the guess in the secret word?
if (guess == secretword[i])
{
guessword[i] = guess;
matches++;
}
}
return matches;
}


// Initialize the unknown word

void initUnknown (char word[], char unknown[])
{
int i;
int length = strlen(word);
for (i = 0; i < length; i++)
unknown[i]='*';
unknown[i]='\0';
}


// Project ends here
@vaseem ambani

Could you please edit you code above to use code tags.

How to use code tags
http://www.cplusplus.com/articles/jEywvCM9/

Anything longer than a few lines is hard to read when un-tagged!

Also, it might help here if you post a summary of the original problem statement, so we can compare that with what your code does.

(And are you someone who has to suffer Turbo C++ ??)

Thanks!

Andy

@Script Coder

Am I the only one who sees all these reported posts?

Nope.

I was just wondering what LB had done to deserve being reported.

Andy
Last edited on
closed account (28poGNh0)
this is what i had submitted which got rejected
Can you tell us why,or how?

Great project ,I dont know why it is rejected, I can only think that you did not use data structor

I did a couple changes

# include <iostream.h> : it is not standarized, this one is
1
2
# include <iostream>
using namespace std;


I realy dont know y you used those statements notice mine
1
2
randomize();
int n=random(10);


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# include <iostream>
# include <stdlib.h>
# include <string.h>
# include <conio.h>
using namespace std;

const int MAXLENGTH=80;
const int MAX_TRIES=5;
const int MAXROW=7;

int letterFill (char, char[], char[]);
void initUnknown (char[], char[]);

int main ()
{
    char unknown[MAXLENGTH],word[MAXLENGTH];
    char letter;
    int num_of_wrong_guesses=0;
    char words[][MAXLENGTH] =
    {
        "india",
        "pakistan",
        "nepal",
        "malaysia",
        "philippines",
        "australia",
        "iran",
        "ethiopia",
        "oman",
        "indonesia"
    };

    //choose and copy a word from array of words randomly

    int n = rand()%9;
    strcpy(word,words[n]);

    // Initialize the secret word with the * character.
    initUnknown(word, unknown);

    // welcome the user
    cout << "\n\nWelcome to hangman...Guess a country Name";
    cout << "\n\nEach letter is represented by a star.";
    cout << "\n\nYou have to type only one letter in one try";
    cout << "\n\nYou have " << MAX_TRIES << " tries to try and guess the word.";
    cout << "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";

    // Loop until the guesses are used up
    while(num_of_wrong_guesses < MAX_TRIES)
    {
        cout << "\n\n" << unknown;
        cout << "\n\nGuess a letter: ";
        cin >> letter;
        // Fill secret word with letter if the guess is correct,
        // otherwise increment the number of wrong guesses.
        if (letterFill(letter, word, unknown)==0)
        {
            cout << endl << "Whoops! That letter isn't in there!" << endl;
            num_of_wrong_guesses++;
        }
        else cout << endl << "You found a letter! Isn't that exciting!" << endl;

        // Tell user how many guesses has left.
        cout << "You have " << MAX_TRIES - num_of_wrong_guesses;
        cout << " guesses left." << endl;
        // Check if they guessed the word.
        if (strcmp(word, unknown) == 0)
        {
            cout << word << endl;
            cout << "Yeah! You got it!";
            break;
        }
    }

    if(num_of_wrong_guesses == MAX_TRIES)
    {
        cout << "\nSorry, you lose...you've been hanged." << endl;
        cout << "The word was : " << word << endl;
    }

    getch();

    return 0;
}

// Initialize the unknown word

void initUnknown(char word[], char unknown[])
{
    int i;
    int length = strlen(word);

    for (i = 0; i < length; i++)
        unknown[i]='*';
    unknown[i]='\0';
}

/* Take a one character guess and the secret word, and fill in the
unfinished guessword. Returns number of characters matched.
Also, returns zero if the character is already guessed. */

int letterFill (char guess, char secretword[], char guessword[])
{
    int i;
    int matches=0;

    for (i = 0; secretword[i]!='\0'; i++)
    {
        // Did we already match this letter in a previous guess?
        if (guess == guessword[i])
        return 0;
        // Is the guess in the secret word?
        if (guess == secretword[i])
        {
            guessword[i] = guess;
            matches++;
        }
    }
    return matches;
}
andywestken wrote:
Anything longer than a few lines is hard to read when un-tagged!


something i totally agree
and he might never take a look at this page again
Last edited on
Topic archived. No new replies allowed.