zoukankan      html  css  js  c++  java
  • abc变为cba和ILoveYou变为IevoLuoY

    abc->cba

        Console.WriteLine("请输入:");
        string str = Console.ReadLine();
        char[] chs = str.ToCharArray();
        char[] chs1 = new char[chs.Length];
        for (int i = chs.Length - 1, j = 0; i >= 0; i--, j++)
        {
    
            chs1[j] = chs[i];
    
        }
        string str1 = new string(chs1);
        Console.WriteLine(str1);
    

    I Love You->I evoL uoY

        Console.WriteLine("请输入:");
        string str = Console.ReadLine();
        string[] strNew = str.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        for (int i = 0; i < strNew.Length; i++)
        {
            char[] chs = strNew[i].ToCharArray();
            for (int j = 0; j < chs.Length / 2; j++)
            {
            char temp = chs[j];
            chs[j] = chs[chs.Length - 1 - j];
            chs[chs.Length - 1 - j] = temp;
            }
            strNew[i] = new string(chs);
        }
        str = string.Join(" ", strNew);
        Console.WriteLine(str);
    
  • 相关阅读:
    BZOJ3391: [Usaco2004 Dec]Tree Cutting网络破坏
    python总结二
    python总结一
    评论详解
    C++入门篇十三
    C++入门篇十二
    C++入门篇十一
    C++入门篇十
    C++入门篇九
    c++入门篇八
  • 原文地址:https://www.cnblogs.com/ChaoJieLiu/p/11908390.html
Copyright © 2011-2022 走看看