Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,166 questions

40,722 answers

573 users

How to get the reciprocal of the letters in a string with C#

1 Answer

0 votes
using System;

class Program
{
    static string get_reciprocal(string s) { 
        string tmp = "";
          
        for (int i = 0; i < s.Length; i++) { 
            if (Char.IsUpper(s[i])) { 
                tmp += (char)('Z' - (int)(s[i]) + 'A'); 
            } 
            else if (Char.IsLower(s[i])) { 
                    tmp += (char)('z' - (int)(s[i]) + 'a'); 
                } 
                else { 
                    tmp += s[i];
            } 
        } 
        return tmp;
    }
    static void Main() {
        string s = "abc++def";
        
        s = get_reciprocal(s); 
        
        Console.Write(s);
    }
}



/*
run:

zyx++wvu

*/

 





answered Jan 19, 2020 by avibootz

Related questions

1 answer 74 views
1 answer 85 views
1 answer 511 views
1 answer 431 views
...