#include "iostream.h"
#include "math.h"
#define BITS (sizeof (int) * 8-1)
static int Checkflag (int x, int y)
{
int S1 = x >> bits;
int s2 = y >> bits;
S1=abs (S1);
S2=abs (S2);
Return (S1 * 2 + s2);
}
static int samesign (int Flag, int x, int y)
{
int t[2] = {x, y};
Long z = x-y;
int s = z >> (bits+32);
S=abs (s);
return T[s];
}
static int diffsign (int flag,int x,int y) comparison
{
int t[2] = {x, y};
return t[flag-1];
}
static int (*funclist[4]) (int flag,int x,int y) ={samesign, diffsign, Diffsign, samesign};
static int Max (int x, int y)
{
int Flag = Checkflag (x, y);
Return (*funclist[flag]) (flag,x,y);
}
void Main ()
{
int x,y,z;
cout<< "Please enter the value of Integer x ( -32768~32767):";
cin>>x;
cout<< "Please enter the value of the integer Y ( -32768~32767):";
cin>>y;
Z=max (X,y);
cout<< "The largest number:" <<z<<endl;
}
#define BITS (sizeof (int) * 8-1)//number of digits moved
static int samesign (int Flag, int x, int y)//Function function: Comparison of x,y with same number
static int diffsign (int flag,int x,int y)//Function function: Comparison of x,y of different numbers
static int (*funclist[4]) (int flag,int x,int y) ={samesign, diffsign, Diffsign, samesign}; To define an array of function pointers
static int Max (int x, int y)//function function: Find the maximum value
static int Checkflag (int x, int y)//function function: detecting x,y symbols
/*
Flag 的值
+ +:0
- +;1
+ 1:2
- -:3
*/