level 4
一 pascal的乘法口诀程序:
program Main;
var i,j:integer;
begin
writeln;
write('乘法口诀');
writeln;
writeln;
for i:=1 to 9 do
begin for j:=1 to i do write(i,'x',j,'=',i*j:2,' ');
writeln;
end;
end.
二 Basic乘法口诀程序
2 print
4 print "云码Basic乘法口诀"
10 FOR i = 1 TO 9
20 FOR j = i TO 9
22 p=i*j
30 PRINT i;" x "; j ;"=";p
40 NEXT j
60 NEXT i
怎么感觉Basic程序要简单、明了一些。
pascal反而复杂。
2022年03月22日 14点03分
1
level 11
1 x 1 = 1 2 x 2 = 4 3 x 3 = 9
1 x 2 = 2 2 x 3 = 6
1 x 3 = 3
如果要这种格式呢?
2022年06月17日 11点06分
3
level 11
3楼的问题我自己挽尊一下,注意到规律是每一行两个因数之间的差从 0 逐渐增加到 8,
所以把循环的语句改写为如下形式即可。
for i := 0 to 8 do begin
for j := 1 to 9 do if i+j<9 then
write(j,'x',i+j,'=',j*(i+j):2,' ');
writeln
end
2022年09月16日 16点09分
6
level 12
看来您是使用Basic的专业人士,能麻烦您把下面的Pascal代码转成Basic吗?万分感激
program FQs;
var
a:array of longint;
l:longint;
i:longint;
procedure E(var a,b:longint);
var
c:longint;
begin
c:=a;
a:=b;
b:=c;
end;
procedure S(n,u:longint);
var
p,i,j:longint;
begin
if n+1=u then
begin
if a[n]>a[u] then E(a[n],a[u]);
end
else
begin
p:=a[n];
i:=n;
j:=u+1;
repeat
i:=i+1;
j:=j-1;
if i=j then
begin
if p<a[i] then
begin
E(a[n],a[i-1]);
if n<(i-1)-1 then S(n,(i-1)-1);
if (i-1)+1<u then S((i-1)+1,u);
Exit;
end
else
begin
E(a[n],a[i]);
if n<i-1 then S(n,i-1);
if i+1<u then S(i+1,u);
Exit;
end;
end
else
begin
for i:=i to j-1 do
if a[i]>p then break;
if i+1<j then
begin
for j:=j downto i+1 do
if a[j]<p then break;
E(a[i],a[j]);
if j-1=i then
begin
if p<a[i] then
begin
E(a[n],a[i-1]);
if n<(i-1)-1 then S(n,(i-1)-1);
if (i-1)+1<u then S((i-1)+1,u);
Exit;
end
else
begin
E(a[n],a[i]);
if n<i-1 then S(n,i-1);
if i+1<u then S(i+1,u);
Exit;
end;
end;
end
else
begin
if a[i]>a[j] then
E(a[i],a[j]);
if p<a[i] then
begin
E(a[n],a[i-1]);
if n<(i-1)-1 then S(n,(i-1)-1);
if (i-1)+1<u then S((i-1)+1,u);
Exit;
end;
if p=a[i] then
begin
if n<i-1 then S(n,i-1);
if i+1<u then S(i+1,u);
Exit;
end;
if p>a[i] then
if p<=a[j] then
begin
E(a[n],a[i]);
if n<i-1 then S(n,i-1);
if i+1<u then S(i+1,u);
Exit;
end
else
begin
E(a[n],a[j]);
if n<j-1 then S(n,j-1);
if j+1<u then S(j+1,u);
Exit;
end;
end;
end;
until (i+1=j) or (i=j);
end;
end;
begin
a:=[];
readln(l);
setlength(a,l);
for i:=0 to l-1 do
read(a[i]);
readln;
S(0,l-1);
for i:=0 to l-1 do
write(a[i],' ');
writeln;
end.
2022年10月15日 22点10分
7
level 1
' Gambas module file
'九几年教pascal的时候,极其讨厌它的啰哩啰嗦语法,C语言里半个大括号的事,它独占一行罗嗦半天,把个程序弄得羊拉屎一样
'这个程序没有注释,用了递归,也不知道是干啥用的,懒得分析了,机械的翻译成basic语言(linux下的Gambas),将就看吧
Public a As New Long[]
Public Sub Main()
Dim l, i As Long
Input l
a.Resize(l)
For i = 0 To l - 1
Input a[i]
Next
S(0, l - 1)
For i = 0 To l - 1
Print a[i]; " ";
Next
Print
End
Sub S(n As Long, u As Long)
Dim p, i, j As Long
If n + 1 = u Then
If a[n] > a[u] Then Swap a[n], a[u]
Else
p = a[n]
i = n
j = u + 1
Do
i = i + 1
j = j - 1
If i = j Then
If p < a[i] Then
Swap a[n], a[i - 1]
If n < (i - 1) - 1 Then S(n, (i - 1) - 1)
If (i - 1) + 1 < u Then S((i - 1) + 1, u)
Else
Swap a[n], a[i]
If n < i - 1 Then S(n, i - 1)
If i + 1 < u Then S(i + 1, u)
Endif
Return
Else
For i = i To j - 1 '这样使用循环变量,是认真的么?
If a[i] > p Then Break
Next
If i + 1 < j Then
For j = j To i + 1 Step -1 '怪异的循环变量用法
If a[j] < p Then Break
Next
Swap a[i], a[j]
If j - 1 = i Then
If p < a[i] Then
Swap a[n], a[i - 1]
If n < (i - 1) - 1 Then S(n, (i - 1) - 1)
If (i - 1) + 1 < u Then S((i - 1) + 1, u)
Else
Swap a[n], a[i]
If n < i - 1 Then S(n, i - 1)
If i + 1 < u Then S(i + 1, u)
Endif
Return
Endif
Else
If a[i] > a[j] Then Swap a[i], a[j]
If p < a[i] Then
Swap a[n], a[i - 1]
If n < (i - 1) - 1 Then S(n, (i - 1) - 1)
If (i - 1) + 1 < u Then S((i - 1) + 1, u)
Else If p = a[i] Then
If n < i - 1 Then S(n, i - 1)
If i + 1 < u Then S(i + 1, u)
Else If p > a[i] Then
If p <= a[j] Then
Swap a[n], a[i]
If n < i - 1 Then S(n, i - 1)
If i + 1 < u Then S(i + 1, u)
Else
Swap a[n], a[j]
If n < j - 1 Then S(n, j - 1)
If j + 1 < u Then S(j + 1, u)
Endif
Endif
Return
Endif
Endif
Loop Until (i + 1 = j) Or (i = j)
Endif
End
2023年04月09日 12点04分
8