zoukankan      html  css  js  c++  java
  • 练习题 英文正常语句倒序书写,标点位置不变

    原文发布时间为:2009-03-09 —— 来源于本人的百度文章 [由搬家工具导入]

    //算法依据:先整句全倒序,然后遇见空格就把前面的单词再倒序。

    using System;// "i come from XiaMen. "变成 " XiaMen. from come i "
    namespace unname
    {
    public class Class2
        {
          public static void Main()
          {
              char[] str = " i come from XiaMen. ".ToCharArray();
              char temp;
              int i = 0, j = str.Length - 1;
              while (i < j)
              {
                  temp = str[i];
                  str[i] = str[j];
                  str[j] = temp;
                  i++;
                  j--;
              }
              i = 0;
              for (int k = 0; k < str.Length; k++)
              {
                  if (str[k] == ' ')
                  {
                      j = k - 1;
                      while (i < j)
                      {
                          temp = str[i];
                          str[i] = str[j];
                          str[j] = temp;
                          i++;
                          j--;
                      }
                      i = k + 1;
                  }
              }
              Console.WriteLine(str);
              Console.ReadLine();

          }

        }
    }

  • 相关阅读:
    STUN协议简介
    AssetManager asset使用
    采购申请 POCIRM-001:ORA-01403: 无论数据未找到
    Windows7在自由的虚拟机(微软官方虚拟机)
    C面试题
    热血江湖按键精灵脚本游戏!
    System.setProperty()
    Linux下patch打补丁命令
    Eclipse和PyDev搭建python开发环境
    二维数组中的查找
  • 原文地址:https://www.cnblogs.com/handboy/p/7153262.html
Copyright © 2011-2022 走看看