将C++翻译成PASCAL

来源:百度知道 编辑:UC知道 时间:2024/06/28 04:50:53
#include<iostream.h>
int main()
{
int a,i,b,n,x;
cin>>x;
for(a=1;a<x;a++)
{
for(b=0,i=1;i<=a/2;i++)
{if(a%i==0)b+=i;}
if (a<b)
{for(n=0,i=1;i<=b/2;i++)
{if(b%i==0)n+=i;}
if (n==a)
cout<<a<<" "<<b<<endl; }}
//system("pause");
return 0;

}

program cpp;
uses crt;
var a,i,n,b,x:integer;

begin

read(x);

for a:=1 to x-1 do
begin
b:=0;
for i:=0 to round(int(a/2)) do
if ((a mod i)=0) then b:=b+i;
if (a<b) then begin
n:=0;
for i:=0 to round(int(b/2)) do
if ((b mod i)=0) then n:=n+i;
if (n=a) then writeln(a,' ',b);
end;
end;
end.

program project1;
var
n,i,j,a,b,x:longint;
procedure main;
begin
read(x);
for a:=1 to x-1 do
begin
b:=0;
for i:=1 to a div 2 do
if a mod i=0
then inc(b,i);
if a<b
then begin
n:=0;
for i:=1 to b div 2 do
if b mod i=0
then inc(n,i);
if n=a