C#练习题答案: 简单的乐趣#69:同样强大?【难度:1级】--景越C#经典编程题库,1000道C#基础练习题等你来挑战

简单的乐趣#69:同样强大?【难度:1级】:

答案1:

namespace myjinxin
{
    using System;
    using System.Linq;
    
    public class Kata
    {
        public bool AreEquallyStrong(int yourLeft, int yourRight, int friendsLeft, int friendsRight)
        {
          int[]yourPower = {yourLeft, yourRight};
          int[]friendsPower = {friendsLeft, friendsRight};
          return yourPower.Max()==friendsPower.Max() && yourPower.Min()==friendsPower.Min();         
        }
    }
}​

答案2:

namespace myjinxin
{
    using System;
    
    public class Kata
    {
        public bool AreEquallyStrong(int YourLeft, int YourRight, int FriendsLeft, int FriendsRight)
        {
            return (YourLeft < YourRight) == (FriendsLeft < FriendsRight)
                ? YourLeft == FriendsLeft &amp;&amp; YourRight == FriendsRight
                : YourLeft == FriendsRight &amp;&amp; YourRight == FriendsLeft;
        }
    }
}​

答案3:

namespace myjinxin
{
    using System;
    
    public class Kata
    {
        public bool AreEquallyStrong(int YourLeft, int YourRight, int FriendsLeft, int FriendsRight){
          bool flag;
          if(YourLeft == FriendsLeft || YourLeft == FriendsRight || YourRight == FriendsLeft || YourRight == FriendsRight)
            flag = YourLeft + YourRight == FriendsLeft + FriendsRight;
          else
            flag = false;
          return flag;
        }
    }
}​

答案4:

namespace myjinxin
{
    using System;
    
    public class Kata
    {
        public bool AreEquallyStrong(int yl, int yr, int fl, int fr)
        {
            int yw, ys, fw, fs;

            if (yl < yr)
            {
                yw = yl;
                ys = yr;
            }
            else
            {
                yw = yr;
                ys = yl;
            }

            if (fl < fr)
            {
                fw = fl;
                fs = fr;
            }
            else
            {
                fw = fr;
                fs = fl;
            }

            return yw == fw &amp;&amp; ys == fs;
        }
    }
}​

答案5:

namespace myjinxin
{
    using System;
    using System.Linq;
    using System.Collections.Generic;
    public class Kata
    {
public bool AreEquallyStrong(int YourLeft, int YourRight, int FriendsLeft, int FriendsRight){
  return Math.Max(YourLeft, YourRight)==Math.Max(FriendsLeft, FriendsRight)&amp;&amp;Math.Min(YourLeft, YourRight)==Math.Min(FriendsLeft, FriendsRight);
} 

    }
}​

答案6:

namespace myjinxin
{
    using System;
    
    public class Kata
    {
        public bool AreEquallyStrong(int YourLeft, int YourRight, int FriendsLeft, int FriendsRight){
          //coding and coding..
        if(YourLeft==FriendsLeft&amp;&amp;YourRight==FriendsRight)
        {
          return true;
        }
        
        else if(YourLeft==FriendsRight&amp;&amp;YourRight==FriendsLeft)
        {
          return true;
        }
        
        else return false;
          
        }
    }
}​

答案7:

namespace myjinxin {
    using System;

    public class Kata {
        public bool AreEquallyStrong( int YourLeft, int YourRight, int FriendsLeft, int FriendsRight ) {
            return Math.Max( YourLeft, YourRight ) == Math.Max( FriendsLeft, FriendsRight ) &amp;&amp;
                   Math.Min( YourLeft, YourRight ) == Math.Min( FriendsLeft, FriendsRight );
        }
    }
}​

答案8:

namespace myjinxin
{
    using System;
    
    public class Kata
    {
        public bool AreEquallyStrong(int YourLeft, int YourRight, int FriendsLeft, int FriendsRight){
          
          int yS = Math.Max(YourLeft, YourRight);
          int yW = Math.Min(YourLeft, YourRight);
          
          int fS = Math.Max(FriendsLeft, FriendsRight);
          int fW = Math.Min(FriendsLeft, FriendsRight);
          
          return yS == fS &amp;&amp; yW == fW;
        }
    }
}​

答案9:

namespace myjinxin
{
  using System;
    
  public class Kata
  {
    public bool AreEquallyStrong(int YourLeft, int YourRight, int FriendsLeft, int FriendsRight)
    {
      return Math.Min(YourLeft, YourRight) == Math.Min(FriendsLeft, FriendsRight) &amp;&amp; Math.Max(YourLeft, YourRight) == Math.Max(FriendsLeft, FriendsRight);
    }
  }
}​

答案10:

namespace myjinxin
{
    using System;
    
    public class Kata
    {
        public bool AreEquallyStrong(int a1, int a2, int b1, int b2){
           return a1+a2 == b1+b2 &amp;&amp; a1*a2 == b1*b2;
         
        }
    }
}​

上一篇:前端页面传送特殊字符串& % 的处理


下一篇:机器学习基石第一讲:The Learning Problem