(1)~(5)をお願いします。
Posted: 2011年2月03日(木) 13:29
構造体では、代入は可能であるが、等価演算子(==と!=)による比較を直接行うことができないので、メンバ単位で等しいか否かを判断する必要がある。いま、複素数を表す構造体型complexを定義し、以下に示すような、メンバreとimが共に等しければ1(int型)を、そうでなければ0(int型)を返す関数complex_eqを考えた。
typedef struct {doubule re, im;} ( 1 );
int complex_eq(complex x, complex y)
{
int flag = 1;
if (x. re ( 2 ) y. re ( 3 ) x. im ( 2 ) y. im)
flag = ( 4 ) ;
return ( ( 5 ) );
}
typedef struct {doubule re, im;} ( 1 );
int complex_eq(complex x, complex y)
{
int flag = 1;
if (x. re ( 2 ) y. re ( 3 ) x. im ( 2 ) y. im)
flag = ( 4 ) ;
return ( ( 5 ) );
}