密码系统【难度:1级】:
答案1:
using System. Linq;
public class Crisis
{
public static string HelpZoom ( int [ ] a) = > a. Reverse ( ) . SequenceEqual ( a) ? "Yes" : "No" ;
}
答案2:
using System;
using System. Linq;
public class Crisis
{
public static string HelpZoom ( int [ ] key)
{
if ( key == null || key. Length < 2 )
return "No" ;
else
return key. Take ( key. Length / 2 ) . SequenceEqual ( key. Skip ( key. Length / 2 + key. Length % 2 ) . Reverse ( ) ) ? "Yes" : "No" ;
}
}
答案3:
public class Crisis
{
public static string HelpZoom ( int [ ] key)
{
for ( int i= 0 , j= key. Length- 1 ; i< ( key. Length- 1 ) / 2 ; i++ , j-- )
{
if ( key[ i] != key[ j] ) return "No" ;
}
return "Yes" ;
}
}
答案4:
public class Crisis
{
public static string HelpZoom ( int [ ] key)
{
for ( int i = 0 ; i < key. Length / 2 ; i++ )
{
if ( key[ i] != key[ key. Length - 1 - i] ) return "No" ;
}
return "Yes" ;
}
}
答案5:
public class Crisis
{
public static string HelpZoom ( int [ ] key)
{
for ( int i = 0 ; i < key. Length/ 2 ; i++ )
if ( key[ i] != key[ key. Length - 1 - i] )
return "No" ;
return "Yes" ;
}
}
答案6:
using System;
public class Crisis
{
public static string HelpZoom ( int [ ] key)
{
string s1 = "" , s2 = "" ;
for ( int i = 0 , j = key. Length- 1 ; i < key. Length; i++ , j-- )
{
s1 + = key[ i] . ToString ( ) ;
s2 + = key[ j] . ToString ( ) ;
}
return s1 == s2 ? "Yes" : "No" ;
}
}
答案7:
using System;
using System. Collections. Generic;
public class Crisis
{
public static string HelpZoom ( int [ ] key)
{
bool isSym = true ;
bool isRep = key. Length / 2 != 0 ? true : false ;
int helpArraySize = key. Length - 1 ;
if ( isRep) {
for ( int x = 0 ; x <= helpArraySize; x++ )
{
if ( key[ x] != key[ helpArraySize - x] )
{
isSym = false ;
break ;
}
}
}
return ( isRep & amp; & amp; isSym) ? "Yes" : "No" ;
}
}
答案8:
public class Crisis
{
public static string HelpZoom ( int [ ] key)
{
for ( int i= 0 ; i< key. Length/ 2 ; i++ )
if ( key[ i] != key[ key. Length- i- 1 ] ) return "No" ;
return "Yes" ;
}
}
答案9:
public class Crisis
{
public static string HelpZoom ( int [ ] key)
{
for ( int i= 0 ; i< key. Length/ 2 ; i++ )
{
if ( key[ i] != key[ key. Length- i- 1 ] )
return "No" ;
}
return "Yes" ;
}
}
答案10:
public class Crisis
{
public static string HelpZoom ( int [ ] key)
{
for ( int i = 0 ; i < key. Length / 2 ; i++ )
{
if ( key[ i] != key[ key. Length- i- 1 ] )
return "No" ;
}
return "Yes" ;
return string . Empty;
}
}
答案11:
using System;
using System. Linq;
public class Crisis
{
public static string HelpZoom ( int [ ] key) = > IsSymmetric ( key) ? "Yes" : "No" ;
public static bool IsSymmetric ( int [ ] values) = > values != null & amp; & amp; IsSquare ( values. Length) & amp; & amp; values. SequenceEqual ( values. Reverse ( ) ) ;
public static bool IsSquare ( int n) = > Math. Abs ( Math. Sqrt ( n) % 1 ) <= ( double . Epsilon * 100 ) ;
}
答案12:
using System;
using System. Collections. Generic;
using System. Linq;
public class Crisis
{
public static string HelpZoom ( int [ ] key)
{
var reversed = key. Reverse ( ) . ToArray ( ) ;
int counter = 0 ;
for ( int i = 0 ; i < key. Length; i++ )
{
if ( reversed[ i] == key[ i] )
counter++ ;
}
return counter == key. Length ? "Yes" : "No" ;
}
}
答案13:
public class Crisis
{
public static string HelpZoom ( int [ ] key)
{
int longitud = key. Length;
for ( int i= 0 ; i< longitud/ 2 ; i++ )
{
if ( key[ i] != key[ longitud- i- 1 ] ) return "No" ;
}
return "Yes" ;
}
}