Урок 13.1 Задача 22
Primary tabs
Пользователь передает целые положительные число N и M, выведете на экран последовательность от 1 до N, так чтобы ширина "ёлочки" увеличивалась до M чисел, то уменьшалась до 1.
var a,chs,n,m,nchs,flag: integer; begin writeln('vvedite chisla n u m: '); readln(n,m); a:=1; chs:=1; nchs:=1; while (a<=n) do if chs<=nchs then begin write(a, ' '); a:=a+1; chs:=chs+1; end else begin if (nchs=m) then flag:=1 else if (nchs=1)then flag:=0; if (chs<=m)and(flag=0) then begin writeln(); nchs:=nchs+1; chs:=1; end else begin writeln(); nchs:=nchs-1; chs:=1; end; end; readln(); end.
- Log in to post comments
- 305 reads