下麵的簡單示例程式演示了邏輯運算符。複製並粘貼以下Euphoria 程式在test.ex檔並運行這個程式:
#!/home/euphoria-4.0b2/bin/eui integer a = 1 integer b = 0 integer c = 1 printf(1, "a and b = %d\n", (a and b) ) printf(1, "a or b = %d\n", (a or b) ) printf(1, "a xor b = %d\n", (a xor b) ) printf(1, "a xor c = %d\n", (a xor c) ) printf(1, "not(a) = %d\n", not(a) ) printf(1, "not(b) = %d\n", not(b) ) |
這將產生下麵的結果。這裏0表示false,1表示true:
a and b = 0 a or b = 1 a xor b = 1 a xor c = 0 not(a) = 0 not(b) = 1 |
注: 其他的Euphoria數據類型例如Euphoria支持所有上述操作序列,原子和對象。
上一篇:
Euphoria運算符
下一篇:
Euphoria 賦值運算符