pascal语言问题

来源:百度知道 编辑:UC知道 时间:2024/05/13 03:14:56
if (a,b,c,d,e,f,g互不相等)
then ……
在pasca中怎么表示
能具体一点么?不是很懂

if ((not(a in [b,c,d,e,f])) and (not(b in [a,c,d,e,f])) and (not(c in [a,b,d,e,f])) and (not(d in [a,b,c,e,f)) and (not(e in [a,b,c,d,f])) and (not(f in [a,b,c,d,e]))) then ......『这种比楼上的简单方法简单,不过用函数更好,不知道你学了函数没』

if(a!=b&&a!=c.....&&e!=f)
then.....

呵呵,首先,直接判断它们互不相等的语句是没有的。
有两种方法,
第一种简单的:
if (a<>b)and(a<>c)and(a<>d)and(a<>e)and(a<>f)and(a<>g)and......and(f<>g) then……

第二种是编写一个函数来判断。

一个最简单也绝对正确的:

if ((a and b and c and d and e and f and g))=((a or b or c or d or e or f or g)) then ...

原理是位运算

(上面的括号可以不加,我只是为了看得清楚)