Reputation: 247
Vector data: Mary Daryl Cherry
Mary vector position[0]
Daryl vector position[1]
Cherry vector position[2]
Vector size: 3
Vector name: data
No need for Mary [ if vector[0], then display vector[1] and vector[2])
Scene 0: Daryl is on Scene_0 Cherry is on Scene_0
No need for Daryl ( if vector[1], then display vector[0] and vector[2])
Scene 1: Mary is on Scene_1 Cherry is on Scene_1
No need for cherry( if vector[2], then display vector[0] and vector[1])
Scene 2:
Mary is on Scene_2 Daryl is on Scene_2
How do i display at such above? It seems kinda hard to display
data.erase(data.begin());
for(int i=0; i<data.size(); i++)
{
cout<<data[i]<<is on Scene_[i];
}
Thanks in advance!
Upvotes: 0
Views: 82
Reputation: 14510
For you problem, I think an inner loop can do easily the problem :
unsigned int size = data.size();
for( unsigned int i = 0; i < size; i++ )
{
for ( unsigned int j = 0; j < size; j++ )
{
if ( i != j )
{
cout << data[j] << " is on Scene_" << i;
}
}
}
You can see it working here : http://ideone.com/oYEIHY.
Maybe you should look at http://www.cplusplus.com/doc/tutorial/control/, because you seem not very familiar with the structures. For example, the if
statement is a loop...
Upvotes: 2