#2406: 錯誤???


jerry311 (jerry)

學校 : 香港科技大學
編號 : 6622
來源 : [138.19.176.176]
最後登入時間 :
2021-05-04 02:14:59
d155. 序章-永夜抄-A -- witch | From: [113.254.98.121] | 發表日期 : 2009-09-22 23:26

LINE100 WA了...
是我的問題嗎???


#include<stdio.h>
main(){
       char in[200],in2[200];
       long int bwin,lwin;
       bwin=0;
       lwin=0;
     while(scanf("%s %s",in, in2)!=EOF)
     {
          if(in[0]=='G')
          {
              if(lwin>=bwin)
                  puts("悲慘的籌措起香油錢");
                      else
                          puts("螢火的蹤跡");
          bwin=0;lwin=0;
          continue;
          }
         
          if(in[0]=='S' &&  in[1]=='c')             /*scissors*/   //白木的判斷方法

          {
              if(in2[0]=='S' &&  in2[1]=='t')      //stone

                  {
                              lwin++;
                              puts("靈夢獲勝");
                  }
              else if(in2[0]=='P')                      //paper
                       {
                                   bwin++;
                                   puts("紫獲勝");
                       }
          }
          else if(in[0]=='S' &&  in[1]=='t')
          {
              if(in2[0]=='P')
                  {
                              lwin++;
                              puts("靈夢獲勝");
                  }
                  else if(in2[0]=='S' &&  in2[1]=='c')
                      {
                                  bwin++;
                                  puts("紫獲勝");
                      }
          }
          else if(in[0]=='P')
          {
              if(in2[0]=='S' &&  in2[1]=='c')
                  {
                              lwin++;
                              puts("靈夢獲勝");
                  }
                  else if(in2[0]=='S' &&  in2[1]=='t')
                      {
                                   bwin++;
                                   puts("紫獲勝");
                      }
          }        
     }

}

 
#2409: Re:錯誤???


david942j (文旋)

學校 : 臺北市立成功高級中學
編號 : 6086
來源 : [115.43.75.16]
最後登入時間 :
2017-02-18 13:17:39
d155. 序章-永夜抄-A -- witch | From: [58.115.136.3] | 發表日期 : 2009-09-24 20:46

LINE100 WA了...
是我的問題嗎???


#include
main(){
       char in[200],in2[200];
       long int bwin,lwin;
       bwin=0;
       lwin=0;
     while(scanf("%s %s",in, in2)!=EOF)
     {
          if(in[0]=='G')
          {
              if(lwin>=bwin)
                  puts("悲慘的籌措起香油錢");
                      else
                          puts("螢火的蹤跡");
          bwin=0;lwin=0;
          continue;
          }
         
          if(in[0]=='S' &&  in[1]=='c')             /*scissors*/   //白木的判斷方法

          {
              if(in2[0]=='S' &&  in2[1]=='t')      //stone

                  {
                              lwin++;
                              puts("靈夢獲勝");
                  }
              else if(in2[0]=='P')                      //paper
                       {
                                   bwin++;
                                   puts("紫獲勝");
                       }
          }
          else if(in[0]=='S' &&  in[1]=='t')
          {
              if(in2[0]=='P')
                  {
                              lwin++;
                              puts("靈夢獲勝");
                  }
                  else if(in2[0]=='S' &&  in2[1]=='c')
                      {
                                  bwin++;
                                  puts("紫獲勝");
                      }
          }
          else if(in[0]=='P')
          {
              if(in2[0]=='S' &&  in2[1]=='c')
                  {
                              lwin++;
                              puts("靈夢獲勝");
                  }
                  else if(in2[0]=='S' &&  in2[1]=='t')
                      {
                                   bwin++;
                                   puts("紫獲勝");
                      }
          }        
     }

}

 

要依照題意

所以要改成這樣:
 while(scanf("%s %s",in, in2)!=EOF)
     {
          if(in[0]=='G')
          {
              if(lwin>bwin)
                  puts("悲慘的籌措起香油錢");
                      else
                          puts("螢火的蹤跡");
          bwin=0;lwin=0;
          continue;
          }
.       

.

.

.

 
ZeroJudge Forum