By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,605 Members | 1,400 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,605 IT Pros & Developers. It's quick & easy.

finding a variable in an array

P: 2
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.
Nov 14 '06 #1
Share this Question
Share on Google+
2 Replies


Banfa
Expert Mod 5K+
P: 8,916
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

Expand|Select|Wrap|Line Numbers
  1. #include "stdio.h"
  2.  
  3. int main()
  4. {
  5.     puts("RRYYPP");
  6.     puts("GGBBPP");
  7.     puts("YYRROO");
  8.     puts("VVBBGG);
  9.  
  10.     return 0;
  11. }
  12.  
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.
Nov 15 '06 #2

P: 9
#include<iostream>
#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;
}
Nov 15 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.