.


:




:

































 

 

 

 


Return false; else return true;




}

// X, Y, Z. public void Show()

{

Console.WriteLine(x + ", " + + ", " + z);

}

}

class TrueFalseDemo { static void Main() {

ThreeD a = new ThreeD(5, 6, 7);

ThreeD b = new ThreeD(10, 10, 10); ThreeD = new ThreeD (0, 0, 0);

Console.Write(" a: ");

A.Show ();

Console.Write(" b: ");

B.Show();

Console.Write(" : ");

C.Show();

Console.WriteLine();

if(!a) Console.WriteLine(" .") if(!b) Console.WriteLine(" b .") if(!c) Console.WriteLine(" .")

if( & b) Console.WriteLine("a & b ."); else Console.WriteLine("a & b .");

if(a & c) Console.WriteLine("a & ."); else Console.WriteLine("a & .");

if(a | b) Console.WriteLine("a | b ."); else Console.WriteLine("a | b .");

if (a | c) Console.WriteLine("a | ."); else Console.WriteLine("a | .");

}

}

.

: 5, 6, 1

: 10, 10, 10

: 0, 0, 0

.

& b , & . | b , | .

&, | ! bool. , , .. , bool. , C# bool. bool . , , , .

& & | | , . -, & |. -, & | , , . -, , . -, true false. , .

, & | ThreeD, & & | |.

/* !, | & ThreeD.

&& || . */

Using System;

// , class ThreeD {

int , , z; //

public ThreeD() { = = z = 0; }

public ThreeD(int i, int j, int k) { x = i; = j; z = k; }

// | , public static ThreeD operator |(ThreeD opl, ThreeD op2)

{

Else

Return new ThreeD(0, 0, 0);

}

// & , public static ThreeD operator & (ThreeD opl, ThreeD op2)

{

if(((opl.x!= 0) && (opl.!= 0) && (opl.z!= 0)) &

((op2.x!= 0) && (op2.y!= 0) && (op2.z!= 0)))

Return new ThreeD(1, 1, 1); else

Return new ThreeD(0, 0, 0);

}

// !. public static bool operator!(ThreeD op)

{

If(op) return false; else return true;

}

// true.

public static bool operator true(ThreeD op) { if((op.x!= 0) (op.!= 0) || (op.z!= 0))

return true; //

Else

Return false;

}

// false.

public static bool operator false(ThreeD op) { if((op.x == 0) && (op.y == 0) && (op.z == 0))

return true; //

Else

Return false;

}

// X, Y, Z. public void Show()

{

Console.WriteLine (x + ", " + + ", " + z);

}

}'

class TrueFalseDemo { static void Main() {

ThreeD a = new ThreeD(5, 6, 7);

ThreeD b = new ThreeD(10, 10, 10);

ThreeD = new ThreeD(0, 0, 0);

Console.Write(" a: ");

a.Show();

Console.Write(" b: ");

b.Show();

Console.Write(" : ");

c.Show();

Console.WriteLine();

if (a) Console.WriteLine(" ."); if(b) Console.WriteLine(" b ."); if() Console.WriteLine(" .");

if(!a) Console.WriteLine(" ."); if(!b) Console.WriteLine(" b ."); if(!c) Console.WriteLine(" .");

Console.WriteLine ();

Console.WriteLine(" & |"); if( & b) Console.WriteLine(" & b ."); else Console.WriteLine(" & b .");

if( & ) Console.WriteLine(" & ."); else Console.WriteLine(" & .");

if( | b) Console.WriteLine(" | b ."); else Console.WriteLine(" | b .");

if( | ) Console.WriteLine(" | ."); else Console.WriteLine(" | .");

Console.WriteLine();

// . Console.WriteLine(" " +

" && "); if( && b) Console.WriteLine(" && b ."); else Console.WriteLine(" && b .");

if( && ) Console.WriteLine(" && ."); else Console.WriteLine(" && .");

if( b) Console.WriteLine (" || b ."); else- Console.WriteLine(" || b .");

if ( | | ) Console.WriteLine(" | | ."); else Console.WriteLine(" || .");

}

}





:


: 2016-12-03; !; : 420 |


:

:

,
==> ...

1690 - | 1630 -


© 2015-2024 lektsii.org - -

: 0.018 .