Equivalant

Aug 3, 2013 at 10:18pm
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]) {
Aug 3, 2013 at 10:23pm
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 Aug 3, 2013 at 10:26pm
Aug 3, 2013 at 10:24pm
I can't give you the code you're looking for because I don't know what you're trying to do.
Aug 3, 2013 at 10:28pm
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)]'
Aug 3, 2013 at 10:43pm
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 Aug 3, 2013 at 10:49pm
Aug 4, 2013 at 12:42am
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.
Aug 4, 2013 at 12:46am
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.
Aug 4, 2013 at 1:06am
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.
Aug 4, 2013 at 1:06am
closed account (NUj6URfi)
ors = plural of or
Aug 4, 2013 at 1:09am
don't compare the two planes if I is equal to your loop counter.
Aug 4, 2013 at 1:15am
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
Aug 4, 2013 at 1:26am
you only want to compare planes if the loop counter does not equal I
Aug 4, 2013 at 1:34am
closed account (NUj6URfi)
How?
Aug 4, 2013 at 1:42am
if the loop counter does not equal I, compare the planes
Aug 4, 2013 at 12:48pm
closed account (NUj6URfi)
can you just post the edit of my code please?
1
2
3
I = "confused";
if (I == "confused") { 
cout << "Please help.";
Aug 4, 2013 at 2:30pm
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
}
Aug 4, 2013 at 3:13pm
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 Aug 4, 2013 at 3:14pm
Aug 4, 2013 at 3:27pm
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.