Decrypt the String according to given algorithm | C # implementation of the approach ; Function that returns ( num % 26 ) ; Initialize result ; One by one process all digits of ' num ' ; Function to return the decrypted String ; To store the readonly decrypted answer ; One by one check for each character if it is a numeric character ; Modulo the number found in the String by 26 ; Driver code ; Print the decrypted string
using System ; class GFG { static int MOD = 26 ; static int modulo_by_26 ( String num ) { int res = 0 ; for ( int i = 0 ; i < num . Length ; i ++ ) { res = ( ( res * 10 + ( int ) num [ i ] - '0' ) % MOD ) ; } return res ; } static String decrypt_message ( String s ) { String decrypted_str = " " ; String num_found_so_far = " " ; for ( int i = 0 ; i < s . Length ; ++ i ) { if ( s [ i ] >= '0' && s [ i ] <= '9' ) { num_found_so_far += s [ i ] ; } else if ( num_found_so_far . Length > 0 ) { decrypted_str += ( char ) ( ' a ' + modulo_by_26 ( num_found_so_far ) ) ; num_found_so_far = " " ; } } if ( num_found_so_far . Length > 0 ) { decrypted_str += ( char ) ( ' a ' + modulo_by_26 ( num_found_so_far ) ) ; } return decrypted_str ; } public static void Main ( String [ ] args ) { String s = "32ytAAcV4ui30hf10hj18" ; Console . Write ( decrypt_message ( s ) ) ; } }