Equivalant

closed account (NUj6URfi)
Want is the equivalent to this line of code. It gets errors.

 
if (plane[i] == plane[0-i] or plane[i-499]) {
if ( plane[i] == plane[0-i] || plane[i] == plane[i-499]) {

or

if ( plane[i] == plane[0-i] or plane[i] == plane[i-499]) {
Last edited on
I can't give you the code you're looking for because I don't know what you're trying to do.
closed account (NUj6URfi)
I am trying to say if I is 203 and plane is the same as another plane, say plane182 in my plane array, do whatever. Problem is that code can not be compiled do to the error

no match for 'operator||' in 'std::operator== [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>](((const std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)((const std::basic_string<char, std::char_traits<char>, std::allocator<char> >*)((+(((unsigned int)i) * 4u)) + ((std::string*)(&plane))))), ((const std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)((const std::basic_string<char, std::char_traits<char>, std::allocator<char> >*)((+(i * -4u)) + ((std::string*)(&plane)))))) || plane[(i - 499)]'
if I is 203

i == 203

and

&&

plane is the same as

Which plane? Plane[i]?

say plane182 in my plane array,

plane[182]


So if I'm understanding you correctly (which I'm sure I'm not)...

1
2
3
4
if(i == 203 && plane[i] == plane[182])
{
  // do whatever
}




Of course that probably is not what you want. You need to be more clear about what you're trying to do.
Last edited on
closed account (NUj6URfi)
I don't know what I is though. I am saying at a random point In the array is I and if plane[I] == any other plane[whatever] do code. No specific examples please.
Okay so it sounds like you need to compare plane[i] against every other plane in the array.

This means you will have to loop over the whole array and compare against each entry in the array. If any of them are ==, then you can do your code.
closed account (NUj6URfi)
Yes but how can I do that while saying if plane[I] == plane[203] and I is 203 how can I stop the program from running error code easily? I could just use a bunch of ors in a if statement if it wasn't for that issue.
closed account (NUj6URfi)
ors = plural of or
don't compare the two planes if I is equal to your loop counter.
closed account (NUj6URfi)
smart. I have an idea for an algorithim now.

1
2
3
4
5
6
7
8
9
10
11
z = 0;
while (z <= 499) {
if (plane[I] == plane[z]) {
if (I  == z) {
z++ ;
//how do I get it skip the first if statement in this case? 
}
cout << "Plane already logged.";
}

\\continue code
you only want to compare planes if the loop counter does not equal I
closed account (NUj6URfi)
How?
if the loop counter does not equal I, compare the planes
closed account (NUj6URfi)
can you just post the edit of my code please?
1
2
3
I = "confused";
if (I == "confused") { 
cout << "Please help.";
I'm trying not to give you the code because this is about as simple of a logic problem as you can get.

"if the loop counter does not equal I, compare the planes "

1
2
3
4
if( the loop counter does not equal I )
{
    compare the planes
}
closed account (NUj6URfi)
1
2
3
4
5
6
7
8
9
10
z = 0;
while (z <= 499) {
if (I == z) {
z++;
if (plane[I] == plane[z]) {
}
cout << "Plane already logged.";
}

\\continue code


Like that?
Last edited on
Walk through the code:

1
2
3
4
5
6
7
8
9
10
11
12
z = 0;
while (z <= 499)
{
    if (I == z)  // <- comparing I to z
    {
        // <- code in here will only run when I is equal to z
        z++;  // <- only increment z if I is equal to z
        if (plane[I] == plane[z])  // <- only compare planes if I is equal to z
        {
        }
        cout << "Plane already logged.";
    }


So no... that's not what you want.

!= is the "not equal" operator.
Topic archived. No new replies allowed.