Winner in the Rock | C # implementation of the approach ; Function to return the winner of the game ; Both the players chose to play the same move ; Player A wins the game ; Function to perform the queries ; Driver code
using System ; using System . Collections . Generic ; class GFG { static String winner ( String moves ) { Dictionary < char , int > data = new Dictionary < char , int > ( ) ; data . Add ( ' R ' , 0 ) ; data . Add ( ' P ' , 1 ) ; data . Add ( ' S ' , 2 ) ; if ( moves [ 0 ] == moves [ 1 ] ) { return " Draw " ; } if ( ( ( data [ moves [ 0 ] ] | 1 << ( 2 ) ) - ( data [ moves [ 1 ] ] | 0 << ( 2 ) ) ) % 3 != 0 ) { return " A " ; } return " B " ; } static void performQueries ( String [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) Console . Write ( winner ( arr [ i ] ) + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { String [ ] arr = { " RS " , " SR " , " SP " , " PP " } ; int n = arr . Length ; performQueries ( arr , n ) ; } }