我用伪码写了:
s←0
for i=1 to 7 do
{
input(a(i))
a(i)←abs(a(i))
if a(i)∈[0,1] then a(i)=1
s←s+a(i)
}
output(s)