test to see if multiple values are the same

This is a discussion on test to see if multiple values are the same within the C++ Programming forums, part of the General Programming Boards category; it i want to see if for example A B and C are equale can i just type Code: A==B==C...

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    13

    test to see if multiple values are the same

    it i want to see if for example A B and C are equale can i just type
    Code:
    A==B==C

  2. #2
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    Code:
    if ( A==B && B==C )

  3. #3
    Registered User
    Join Date
    Mar 2006
    Posts
    725
    Remember that B==C returns a boolean, like 1 or 0. So you're testing if A==1 or 0. That's how C++ works, deal with it.
    Code:
    #include <stdio.h>
    
    void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){
    puts(a);return;}for(;c<='9';++c){for(f=0;f<9;++f)if(a[i-i%27+i%9
    /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i]
    ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][
    t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}

  4. #4
    Registered User
    Join Date
    May 2006
    Posts
    20
    Quote Originally Posted by jafet
    Remember that B==C returns a boolean, like 1 or 0. So you're testing if A==1 or 0. That's how C++ works, deal with it.
    What he means is
    Quote Originally Posted by Squeaker
    A==B==C
    would check A==B and give a '1' for true or a '0' for false and
    then test if '1'==C

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. My C++ test is COMING!!...
    By [Z-D] in forum C++ Programming
    Replies: 52
    Last Post: 12-01-2006, 07:02 PM
  2. multiple values in #define(?) & counter placement
    By bnmwad in forum C Programming
    Replies: 2
    Last Post: 04-30-2006, 06:00 AM
  3. Returning Multiple Values from a function
    By Eddie K in forum C Programming
    Replies: 6
    Last Post: 03-12-2006, 12:18 PM
  4. returning multiple values from functions?
    By jamesn56 in forum C++ Programming
    Replies: 5
    Last Post: 08-23-2005, 01:10 PM
  5. Replies: 1
    Last Post: 05-01-2003, 02:52 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21