finding a variable in an array

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

    #1

    finding a variable in an array

    ok say I have a program that outputs


    RRYYPP
    GGBBPP
    YYRROO
    VVBBGG

    for example. How would I find a value in the array and have it output something like this:

    RRYYPP
    GGPP
    YYRROO
    VVBBGG

    It's a game called Cross Gnome if that helps any. I'm really stuck and help would be appreciated.
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Originally posted by Kai
    ok say I have a program that outputs


    RRYYPP
    GGBBPP
    YYRROO
    VVBBGG
    This is not descriptive enough of the initial condition for us to be able to understand what you are getting at, for instance this program meets the requirements

    Code:
    #include "stdio.h"
    
    int main()
    {
        puts("RRYYPP");
        puts("GGBBPP");
        puts("YYRROO");
        puts("VVBBGG);
    
        return 0;
    }
    Originally posted by Kai
    How would I find a value in the array and have it output something like this:

    RRYYPP
    GGPP
    YYRROO
    VVBBGG

    It's a game called Cross Gnome if that helps any. I'm really stuck and help would be appreciated.
    Since you have not given an array on which to operate it is hard to say.

    Define you problem more clearly, supply the code you already have.

    Comment

    • christine0207
      New Member
      • Aug 2006
      • 9

      #3
      #include<iostre am>
      #include<string .h>
      using namespace std;

      int main()
      { string arr[4] = {"RRYYPP", "GGBBPP", "YYRROO", "VVBBGG};

      for (int i =0; i <4; i++)
      {
      cout << arr[i] << endl;
      }
      return 0;
      }

      Comment

      Working...