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();

          }

        }
    }

  • 相关阅读:
    10-10-12分页机制(xp)
    段间跳转之任务门
    段间跳转之TSS段
    mysql索引
    cat /proc/meminfo
    This system is not registered to Red Hat Subscription Management报错
    CentOS 6.5安装zabbix
    KVM(系统虚拟化模块)安装
    Linux时区更改
    学习ruby/rails, rvm是必不可少的工具之一
  • 原文地址:https://www.cnblogs.com/handboy/p/7153262.html
Copyright © 2011-2022 走看看