设为首页 加入收藏

TOP

C++关注备注部分知识点
2015-07-24 05:55:08 来源: 作者: 【 】 浏览:6
Tags:关注 备注 部分 知识点

//关注备注部分知识点。
#include 
  
   
#include 
   
     
    //1---需要了解cstring和string之间的区别 int main() { using namespace std; cout<<"Please Enter a string:\n"; string word; cin>>word;// // char temp;
     
    //3--- int i,j; //
     for(i=0,j=word.size()-1;i<=j;++i,--j) 
     for(i=0,j=word.length()-1;i<=j;++i,--j) 
    //2---word.size() word应该是个数组. word.length()和 word.size() 则表示数组的长度. 因为数组下标是从0开始的.所以 要-1 防止下标越界 { char temp;//内部声明temp在每次循环存在被分配和释放,相对for循环体前声明运行慢,循环结束即会释放 // char temp=word[i];
     
    //3--- // char temp=word[i];
     
    //3--- temp=word[i]; word[i]=word[j]; word[j]=temp; } cout<
    
     

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇poj 1201 Intervals(差分约束) 下一篇SRM 622 D2L3: Subsets, math, ba..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: