标题:那位高手帮我将这个pascal程序翻译成C
取消只看楼主
sunyh1999
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:14
帖 子:1178
专家分:3032
注 册:2009-5-17
结帖率:79.37%
已结贴  问题点数:20 回复次数:1 
那位高手帮我将这个pascal程序翻译成C
program ss;

var
   v:array[1..100] of longint;
   s,f,i,j:longint;

begin
   assign(input,'game.in');reset(input);
   assign(output,'game.out');rewrite(output);
   readln(s, f);
   if (f=4)or(f=7) then
   begin
      dec(f);
      for i:=1 to s do read(v[s-i+1]);
   end else
      for i:=1 to s do read(v[i]);
   j:= 0;
   case f of
     1: begin
            j:=s;
            for i:=1 to s-3 do
               if (v[i]=v[i+1])and(v[i]=v[i+2])and(v[i]=v[i+3]) then inc(j);
         end;
     2: begin
            for i:=1 to s-1 do
               if v[i]=v[i+1] then inc(j);
         end;
     3: begin
            for i:=1 to s-1 do
               if v[i]=v[i+1]+1 then inc(j);
            for i:=1 to s-2 do
               if (v[i]=v[i+1])and(v[i]=v[i+2]-1) then inc(j);
         end;
     5: begin
            for i:=1 to s-2 do
               if ((v[i]-v[i+1]=1)or(v[i]-v[i+1]=0))and(v[i]=v[i+2]) then inc(j);
            for i:=1 to s-1 do
               if abs(v[i]-v[i+1])=1 then inc(j);
         end;
     6: begin
            for i:=1 to s-2 do
               if (v[i+1]=v[i+2])and((v[i+1]-v[i]=1)or(v[i+1]-v[i]=0)) then inc(j);
            for i:=1 to s-1 do
               if (v[i]=v[i+1])or(v[i]=v[i+1]+2) then inc(j);
         end;
   end;
   writeln(j);
close(input);
close(output);
end.
搜索更多相关主题的帖子: pascal 翻译 
2010-09-21 18:32
sunyh1999
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:14
帖 子:1178
专家分:3032
注 册:2009-5-17
得分:0 
不是delphi,是pascal代码

欢迎来到我的博客:http://blog..cn/noisunyuhong
2010-09-22 08:40



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-321074-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.765495 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved