C++ Output

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • melaghil
    New Member
    • Nov 2006
    • 2

    C++ Output

    Hi all,

    I'm really having a problem, and it is in the output results.

    There are basically two loops. I want to set the first loop to be in the ouptput in the second loop.

    Here is my code:

    //first loop
    for (int c = 0; c < wordcount; c++) {
    for (int g =1; g < wordcount; g++) {
    if (word[c] == word[g] ) {
    cout << Dictionary[g-1] << endl;
    }
    }
    }

    //second loop
    for (int i = 1 , L = 0; i <= wordcount , L <= wordcount; i++ , L++) {
    cout << word[i] << " " << Dictionary[L] << " " << endl;
    }

    that is to be like this:

    for (int i = 1 , L = 0; i <= wordcount , L <= wordcount; i++ , L++) {
    cout << word[i] << " " << Dictionary[L] << " " <<
    for (int c = 0; c < wordcount; c++) {
    for (int g =1; g < wordcount; g++) {
    if (word[c] == word[g] ) {
    cout << Dictionary[g-1] << endl;
    }
    }
    }
    << endl;
    }


    I tried to include them in a while loop but its not working.
    hope one of you guys will help me out.

    Thanks in advance.
  • kirubanantham
    New Member
    • Nov 2006
    • 8

    #2
    Hai Melaghil,
    I dont understand any thing from your code. please can you clearly explain your problem.

    Cheers
    K.Kiruba.

    Comment

    • melaghil
      New Member
      • Nov 2006
      • 2

      #3
      Thanks for you reply, and sorry for my uncleared wiritng as i was in a rush.

      here is wt the program does.
      Part 1:
      You have a list of the dictionary words stored in a text file. the program takes the words line by line, and sort them in alpahpetical order (anagram),
      so if we have a word called lemon then the output is in this form.

      elmno lemon

      and thats wt is done by this loop

      for (int i = 1 , L = 0; i <= wordcount , L <= wordcount; i++ , L++) {
      cout << anagram[i] << " " << Dictionary[L] << " " << endl;
      }

      Part 2:

      sometimes a word like monel have the same anagram as the word lemon, if this case happened then the output should be like this

      elmno lemon monel


      the problem i have is, i have done part 1, and i want to combine both parts

      here is the seocnd loop that i want to combined with the first one:

      for (int c = 0; c < wordcount; c++) {
      for (int g =1; g < wordcount; g++) {
      if (word[c] == word[g] ) {
      cout << Dictionary[g-1] << endl;
      }
      }
      }

      Hope will clear it more.

      Thanks again

      Comment

      • mohsin
        New Member
        • Nov 2006
        • 19

        #4
        hi
        well would u like to tell me that what do u want from this code i mean i m still doubtfull about your code
        thanks

        Comment

        Working...