"case实现日期
*PARAMETERS: week_7 type i.
*case week_7.
- when 1.
- write:/ '周一'.
- when 2.
- write:/ '周二'.
- when 3.
- write:/ '周三'.
- when 4.
- write:/ '周四'.
- when 5.
- write:/ '周五'.
- when 6.
- write:/ '周六'.
- when 7.
- write:/ '周日'.
- endcase.
"case实现查询日历
*PARAMETERS: year type i,
month type i.
*case month.
- when 1 or 3.
- write:/ '31'.
** when 3.
** write:/ '31'. - when 5.
- write:/ '31'.
- when 7.
- write:/ '31'.
- when 8.
- write:/ '31'.
- when 10.
- write:/ '31'.
- when 12.
- write:/ '31'.
- when 4.
- write:/ '30'.
- when 6.
- write:/ '30'.
- when 9.
- write:/ '30'.
- when 11.
- write:/ '30'.
- when 2.
- if year mod 4 = 0 and year mod 100 <> 0 or year mod 400 = 0.
write:/ '29'.
else.
write:/ '28'.
endif.
- endcase.
"计算100以内的累加和
- data: sum type i,
s type i value 1.
- do 100 times.
- sum = sum + s.
- s = s + 1.
- enddo.
- write:/ sum.
"计算100以内的累加和并输出字段值
- data: sum type i,
s type i value 1.
- do 100 times.
- sum = sum + s.
- s = s + 1.
- enddo.
- write:/ sum.
- clear sum.
- do 8 times.
- sum = sum + sy-index.
- enddo.
*write:/ sum , sy-index.
*clear s.“清空s
*while s <= 15.
s = s + 1.
write:/ s,'sy-index',sy-index.
endwhile.
"求出【m,n】的累加求和
*PARAMETERS: m type i,n type i.
*data:sum type i value 0.
*while m <= n .
- sum = sum + m.
- m = m + 1.
*ENDWHILE.
*write:/ sum.
*else. - WRITE:/ '范围有限'.
"1000以内的水仙花数
data:n type i,
g type i,
s type i,
b type i.
n = 100.
while n < 1000 and n >= 100.
b = n div 100.
s = ( n - b * 100 ) div 10.
g = n mod 10.
if n = b ** 3 + s ** 3 + g ** 3.
write:/ n.
else.
endif.
n = n + 1.
endwhile.
"简单计算器的实现
*PARAMETERS: m1 type i,
m2 type i,
f type c.
*data: s type i.
if f = '+' or f = '-' or f = '' or f = '/'.
- case f.
- when '+'.
s = m1 + m2.
write:/ s.
- when '-'.
s = m1 - m2.
write:/ s.
- when '*'.
s = m1 * m2.
write:/ s.
- when '/'.
s = m1 div m2.
write:/ s.
- ENDCASE.
*else. - write:/ '输入字符错误'.
*endif.