我做了这样的事情(在伪代码中):
for x = 0 to 3
for y = 0 to 3
id1 = m[x][y] * m[y][x];
id2 = m[y][x] * m[x][y];
if id1 != m[x][y] or id1 != id2 then
nn = nn + 1;
else
en = id1;
endif
endfor
endfor
if nn = 0 then
print("There is an identity element: ", en);
a := a + 1;
else
print("There isn't an identity element.");
endif
当我运行它时,以 1,2,3,4 作为我的集合,乘法作为操作,它返回“没有身份元素。”,所以我想我的逻辑有问题。有什么帮助吗?