Написать фрагмент программы, подсчитывающий сумму только положительных из трех данных чисел.
Ответы на вопрос
Ответил Igorrock
0
1 вариант:
If (a>0) or (a=0) and (b>0) or (b=0) and (c>0) or (c=0) Then s:=a+b+c Else
If (a>0) or (a=0) and (b>0) or (b=0) and (c<0) Then s:=a+b Else
If (a>0) or (a=0) and (c>0) or (c=0) and (b<0) Then s:=a+c Else
If (b>0) or (b=0) and (c>0) or (c=0) and (a<0) Then s:=b+c Else
If (a<0) and (b<0) and (c>0) or (c=0) Then s:=c Else
If (a<0) and (c<0) and (b>0) or (b=0) Then s:=b Else s:=a;
2 вариант:
If (a>0) or (a=0) Then s:=s+a;
If (b>0) or (b=0) Then s:=s+b;
If (c>0) or (c=0) Then s:=s+c;
If (a>0) or (a=0) and (b>0) or (b=0) and (c>0) or (c=0) Then s:=a+b+c Else
If (a>0) or (a=0) and (b>0) or (b=0) and (c<0) Then s:=a+b Else
If (a>0) or (a=0) and (c>0) or (c=0) and (b<0) Then s:=a+c Else
If (b>0) or (b=0) and (c>0) or (c=0) and (a<0) Then s:=b+c Else
If (a<0) and (b<0) and (c>0) or (c=0) Then s:=c Else
If (a<0) and (c<0) and (b>0) or (b=0) Then s:=b Else s:=a;
2 вариант:
If (a>0) or (a=0) Then s:=s+a;
If (b>0) or (b=0) Then s:=s+b;
If (c>0) or (c=0) Then s:=s+c;
Новые вопросы