当前位置: 代码迷 >> Java Web开发 >> CSDN没人了吗?母亲救救啊……
  详细解决方案

CSDN没人了吗?母亲救救啊……

热度:15   发布时间:2016-04-17 12:51:23.0
CSDN没人了吗?妈妈救救啊……
怎么实现     字符反转     不能调用库函数        
 
比如:the     china     dalian     microsoft        
反转成为:microsoft     dalian     china     the        
不是         tfosorcim     nailad     anihc     eht    
 
我当时的错误示例:    
错误1:class     a    
{    
                  public     static     void     main(String[]     args)        
                  {    
                                      String     str= "     the     china     dalian     microsoft     ";    
                                      char[]     c=str.toCharArray();    
                                      char[]     temp=new     char[c.length];    
                                      for(int     i=0,j=c.length-1;i <c.length;i++,j--)    
                                      {    
                                                      temp[j]=c[i];    
                                      }    
                                                              System.out.println(temp);    
              }    
}    
 
错误2:    
 
class     b    
{    
                  public     static     void     main(String[]     args)        
                  {    
                          String     a     =     "da     lian     joyesoft ";    
                          String     c     = " ";    
                          StringBuffer     b     =     new     StringBuffer( "the     china     dalian     microsoft     ");    
  相关解决方案