C++转Pascal语言
将以下C++程序转换成Pascal程序急求!越快越好!尽量在8.25日之前解决!#include<stdio.h>#include<string.h>#include<m...
将以下C++程序转换成Pascal程序 急求!越快越好!尽量在8.25日之前解决!
#include<stdio.h>
#include<string.h>
#include<memory.h>
intmain(void)
{intflag=0,h;intnn[5]={0},tt[5]={0},hc[]={0,-50,-2,-3,-4,-5,-6,-7,-8,-9,-10,-20,-30,-40};
inti,j,k,d11,s12,temp,c10;charss[20][6],hh[20][6]="0","H1","H2","H3","H4","H5","H6","H7","H8","H9","H10","H11","H12","H13"};
while(1)
{memset(nn,0,sizeof(nn));memset(tt,0,sizeof(tt));for(i=1;i<=4;i++){
memset(ss,'\0',sizeof(ss));scanf("%d",&nn[i]);for(j=1;j<nn[i];j++)scanf("%s",ss[j]);
if(j<=nn[i]) scanf("%s",ss[j]); if(nn[i]==0) tt[i]=0; elseif(nn[i]==1&&strcmp(ss[1],"C10")==0) tt[i]=50; else {if(nn[i]==16) tt[i]=1000; else {s12=0; d11=0; c10=0; for(h=1;h<=nn[i];h++){if(strcmp(ss[h],"S12")==0)s12=1;elseif(strcmp(ss[h],"D11")==0)d11=1;
elseif(strcmp(ss[h],"C10")==0)c10=1;}if(nn[i]>=13){temp=0;for(k=1;k<=nn[i];k++)
for(h=1;h<=13;h++)if(strcmp(ss[k],hh[h])==0){temp++;break;}if(temp==13){tt[i]=200;
if(s12&&d11)tt[i]+=300;elseif(s12)tt[i]-=100;elseif(d11)tt[i]+=100;if(c10)tt[i]*=2;}else
{for(k=1;k<=nn[i];k++)for(h=1;h<=13;h++)if(strcmp(ss[k],hh[h])==0){
tt[i]+=hc[h];break;}if(s12)tt[i]-=100;if(d11)tt[i]+=100;if(c10)tt[i]*=2;}}else
{for(k=1;k<=nn[i];k++)for(h=1;h<=13;h++)if(strcmp(ss[k],hh[h])==0){tt[i]+=hc[h];break;}
if(s12)tt[i]-=100;if(d11)tt[i]+=100;if(c10)tt[i]*=2;}}}}
if(nn[1]==0&&nn[2]==0&&nn[3]==0&&nn[4]==0)break;
for(k=1;k<=4;k++){if(tt[k]>0)printf("+%d",tt[k]);elseprintf("%d",tt[k]);}}
system("pause");return0;}
注:题目:拱猪游戏 展开
#include<stdio.h>
#include<string.h>
#include<memory.h>
intmain(void)
{intflag=0,h;intnn[5]={0},tt[5]={0},hc[]={0,-50,-2,-3,-4,-5,-6,-7,-8,-9,-10,-20,-30,-40};
inti,j,k,d11,s12,temp,c10;charss[20][6],hh[20][6]="0","H1","H2","H3","H4","H5","H6","H7","H8","H9","H10","H11","H12","H13"};
while(1)
{memset(nn,0,sizeof(nn));memset(tt,0,sizeof(tt));for(i=1;i<=4;i++){
memset(ss,'\0',sizeof(ss));scanf("%d",&nn[i]);for(j=1;j<nn[i];j++)scanf("%s",ss[j]);
if(j<=nn[i]) scanf("%s",ss[j]); if(nn[i]==0) tt[i]=0; elseif(nn[i]==1&&strcmp(ss[1],"C10")==0) tt[i]=50; else {if(nn[i]==16) tt[i]=1000; else {s12=0; d11=0; c10=0; for(h=1;h<=nn[i];h++){if(strcmp(ss[h],"S12")==0)s12=1;elseif(strcmp(ss[h],"D11")==0)d11=1;
elseif(strcmp(ss[h],"C10")==0)c10=1;}if(nn[i]>=13){temp=0;for(k=1;k<=nn[i];k++)
for(h=1;h<=13;h++)if(strcmp(ss[k],hh[h])==0){temp++;break;}if(temp==13){tt[i]=200;
if(s12&&d11)tt[i]+=300;elseif(s12)tt[i]-=100;elseif(d11)tt[i]+=100;if(c10)tt[i]*=2;}else
{for(k=1;k<=nn[i];k++)for(h=1;h<=13;h++)if(strcmp(ss[k],hh[h])==0){
tt[i]+=hc[h];break;}if(s12)tt[i]-=100;if(d11)tt[i]+=100;if(c10)tt[i]*=2;}}else
{for(k=1;k<=nn[i];k++)for(h=1;h<=13;h++)if(strcmp(ss[k],hh[h])==0){tt[i]+=hc[h];break;}
if(s12)tt[i]-=100;if(d11)tt[i]+=100;if(c10)tt[i]*=2;}}}}
if(nn[1]==0&&nn[2]==0&&nn[3]==0&&nn[4]==0)break;
for(k=1;k<=4;k++){if(tt[k]>0)printf("+%d",tt[k]);elseprintf("%d",tt[k]);}}
system("pause");return0;}
注:题目:拱猪游戏 展开
5个回答
展开全部
很长,很烦。当然啦,我只会pascal,不会C语言。你又不告我题目具体内容。那就只有抄了。
program heart;
const h:array [1..13] of longint
=(-50,-2,-3,-4,-5,-6,-7,-8,-9,-10,-20,-30,-40);
var i,j,p,point,total:longint;
ch:char;
pig,sheep,d:boolean;
score:array [1..4] of longint;
begin
assign(input,'heart.in');
reset(input);
assign(output,'heart.out');
rewrite(output);
repeat
total:=0;
for i:=1 to 4 do
begin
score[i]:=0;
pig:=false;
sheep:=false;
d:=false;
read(p);
total:=total+p;
for j:=1 to p do
begin
repeat
read(ch);
until ch>='A';
{ write(ch);}
read(point);
case ch of
'S':pig:=true;
'H':score[i]:=score[i]+h[point];
'D':sheep:=true;
'C':d:=true
end;
{ write(point,' ')}
end;
readln;
if (p=1) and d
then score[i]:=50
else if score[i]<>-194
then begin if pig then score[i]:=score[i]-100;
if sheep then score[i]:=score[i]+100;
if d then score[i]:=score[i]*2
end
else begin
score[i]:=200;
if pig and sheep
then score[i]:=500
else begin
if pig then score[i]:=score[i]-100;
if sheep then score[i]:=score[i]+100
end;
if d then score[i]:=score[i]*2
end;
end;
if total<>0 then
begin
for i:=1 to 4 do
begin
if score[i]>0 then write('+');
write(score[i]);
if i<4 then write(' ')
end;
writeln
end
until total=0;
close(input);
close(output);
end.
这里用的是文件贮存。但我未细看,你要用它干吗呢?
program heart;
const h:array [1..13] of longint
=(-50,-2,-3,-4,-5,-6,-7,-8,-9,-10,-20,-30,-40);
var i,j,p,point,total:longint;
ch:char;
pig,sheep,d:boolean;
score:array [1..4] of longint;
begin
assign(input,'heart.in');
reset(input);
assign(output,'heart.out');
rewrite(output);
repeat
total:=0;
for i:=1 to 4 do
begin
score[i]:=0;
pig:=false;
sheep:=false;
d:=false;
read(p);
total:=total+p;
for j:=1 to p do
begin
repeat
read(ch);
until ch>='A';
{ write(ch);}
read(point);
case ch of
'S':pig:=true;
'H':score[i]:=score[i]+h[point];
'D':sheep:=true;
'C':d:=true
end;
{ write(point,' ')}
end;
readln;
if (p=1) and d
then score[i]:=50
else if score[i]<>-194
then begin if pig then score[i]:=score[i]-100;
if sheep then score[i]:=score[i]+100;
if d then score[i]:=score[i]*2
end
else begin
score[i]:=200;
if pig and sheep
then score[i]:=500
else begin
if pig then score[i]:=score[i]-100;
if sheep then score[i]:=score[i]+100
end;
if d then score[i]:=score[i]*2
end;
end;
if total<>0 then
begin
for i:=1 to 4 do
begin
if score[i]>0 then write('+');
write(score[i]);
if i<4 then write(' ')
end;
writeln
end
until total=0;
close(input);
close(output);
end.
这里用的是文件贮存。但我未细看,你要用它干吗呢?
展开全部
如果让老板看到这样格式的代码肯定把你劈掉了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
怎么没缩进啊,看不清楚啊,很乱啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2009-08-24
展开全部
唔!我不登录回答了。你既学过pascal,还学过c语言?你干吗?把题目、描述、输入输出格式告诉我呀,这样才能做。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这程序干嘛的啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询