帮忙将pascal语言程序改变成C++语言,急用
Programp12-3;Vara,b,c,d:integer;X,x0,x1,x2,x3,x4:integer;st1:setof1..100;functionnumb...
Program p12-3;
Var a,b,c,d:integer;
X,x0,x1,x2,x3,x4:integer;
st1:set of 1..100;
function number(a,b,c,d:integer):integer;
var n1,n2,n3,n4,sum:integer;
begin
st1:=[];
for n1:=0 to 3 do
for n2:=0 to 3-n1 do
for n3:=0 to 3-n1-n2 do
for n4:=0 to 3-n1-n2-n3 do
begin
if n1+n2+n3+n4x0 then
begin
x0:=x;x1:=a;x2:=b;x3:=c;x4:=d;
write(x1:5,x2:5,x3:5,x4:5);
writeln('':10,'x0=',x0);
end;
end;
end. 展开
Var a,b,c,d:integer;
X,x0,x1,x2,x3,x4:integer;
st1:set of 1..100;
function number(a,b,c,d:integer):integer;
var n1,n2,n3,n4,sum:integer;
begin
st1:=[];
for n1:=0 to 3 do
for n2:=0 to 3-n1 do
for n3:=0 to 3-n1-n2 do
for n4:=0 to 3-n1-n2-n3 do
begin
if n1+n2+n3+n4x0 then
begin
x0:=x;x1:=a;x2:=b;x3:=c;x4:=d;
write(x1:5,x2:5,x3:5,x4:5);
writeln('':10,'x0=',x0);
end;
end;
end. 展开
1个回答
2011-06-22
展开全部
//p12-3.c
#include <stdlib.h>
#include <stdio.h>
//int a,b,c,d;没用
int X,x0,x1,x2,x3,x4;
int number(int a,int b,int c,int d)
{
int n1,n2,n3,n4,sum;
for(n1=0;n1<=3;n1++)
{
for(n2=0;n2<=3-n1;n2++)
{
for(n3=0;n3<=3-n1-n2;n3++)
{
for(n4=0;n4<=3-n1-n2-n3;n4++)
{
if((n1+n2+n3+n4) > 0)//没看懂...
{
x0=X;
x1=a;
x2=b;
x3=c;
x4=d;
printf("%05d,%05d,%05d,%05d",x1,x2,x3,x4);
printf("\r\n x0=%d\r\n",x0);
}
}
}
}
}
return 0;
}
void main()
{
number(1,2,3,4);
getchar();
}
#include <stdlib.h>
#include <stdio.h>
//int a,b,c,d;没用
int X,x0,x1,x2,x3,x4;
int number(int a,int b,int c,int d)
{
int n1,n2,n3,n4,sum;
for(n1=0;n1<=3;n1++)
{
for(n2=0;n2<=3-n1;n2++)
{
for(n3=0;n3<=3-n1-n2;n3++)
{
for(n4=0;n4<=3-n1-n2-n3;n4++)
{
if((n1+n2+n3+n4) > 0)//没看懂...
{
x0=X;
x1=a;
x2=b;
x3=c;
x4=d;
printf("%05d,%05d,%05d,%05d",x1,x2,x3,x4);
printf("\r\n x0=%d\r\n",x0);
}
}
}
}
}
return 0;
}
void main()
{
number(1,2,3,4);
getchar();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询