Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #include <cstdio>
  2. #include <cstdlib>
  3.  
  4. bool eq3(int a, int b, int c);
  5.  
  6. int main(int argc, char* argv[])
  7. {
  8.     char input[256];
  9.     int a = 0, b = 0, c = 0;
  10.    
  11.     while(1)
  12.     {
  13.         printf("Type a number: ");
  14.        
  15.         for(short i = 0; i < 256; i++)
  16.             input[0] = 0; // Zero out the char array - ensures a null terminated string.
  17.        
  18.         fscanf(stdin, "%s", input); // Read input from stdin
  19.        
  20.         if(input[0] < 48 || input[0] > 57) // Checks if input is an ascii number, returns false if not
  21.             return 0;
  22.        
  23.         if(a == 0)
  24.             a = atoi(input);
  25.         else if(b == 0)
  26.             b = atoi(input);
  27.         else
  28.         {
  29.             c = atoi(input);
  30.             bool chk = eq3(a, b, c);
  31.            
  32.             if(chk == true)
  33.                 printf("All values are equal.\n");
  34.             else
  35.                 printf("Values are not equal.\n");
  36.            
  37.             a = 0;
  38.             b = 0;
  39.             c = 0;
  40.         }
  41.        
  42.     }
  43.    
  44.     return 0; // This is here to keep the compiler from complaining...
  45. }
  46.  
  47. bool eq3(int a, int b, int c)
  48. {
  49.     int check = a;
  50.    
  51.     a |= (b | c);
  52.    
  53.     if(check != a)
  54.         return false;
  55.     else
  56.         return true;
  57. }