谁能将这个C++程序翻译成pascal啊

来源:百度知道 编辑:UC知道 时间:2024/06/04 08:22:49
第一个程序:
int i, n=42;
main() {
for(i=0; i<n; i--) {
printf("*");
}
}
第二个程序:
#include <stdio.h>

int rex[5];

void f3(int *a) {
int i;
for (i=0; i<5; i++) a[i]=0;
}

int f2(int *a) {
int i;
for (i=0; i<5; i++) if (a[i]!=0) return 0;
return 1;
}

void f1(int *a) {
int i;
for (i=0; i<5; i++) {
a[i]++;
if (a[i]<100) break;
a[i]-=100;
}
for (i=4; i>=0 && a[i]>=rex[i]; i--)
if (a[i]>rex[i])
f3(a);
}

void f4(int *a) {
int i;
for (i=0; i<5; i++) {
a[i]--;
if (a[i]>=0) break;
a[i]+=100;
}
if (i>=5) for (i=0; i<5; i++) a[i]=rex[i];
}

void f7(int *a, int *b) {
int c[5];
f3(c); f3(a);
while(!f2(b)) { f1(a); f4(b); f1(c); }
while(!f2(c)) { f1(b); f4(c); }
}
<

int i, n=42;
main() {
for(i=0; i<n; i--) {
printf("*");
}
}

pascal:
program a;
var i,n:integer;
begin
n:=42;
for i:=0 downto n do{晕 死循环 应该是for(i=0;i<n;i++)吧?那就改成for i:=0 to n do}
write('*');
end.

第一个程序:
var i,n:integer;
begin
n:=42;
for i:=1 to n do write('*');{你的循环有问题,i--一概改成i++}
end.
第二个程序的代码太长了,而且我赶着上课,你把问题说下,我有空帮你编