当前位置:编程学习 > C/C++ >>

帮忙看下C++代码!!!

#include<iostream>
using namespace std;
int main(){
string b="Bnofs`utm`uhnor !Xnt!i`wd!fnu!uid!jdx !On!hoqtu-!xnt!ktru!odde!un!ntuqtu!#Vdmbnld!un![KTU!@BL.HBQB!Ud`l #!vhuintu!uid!ptnu`uhno/";
for(int i=0;i<b.length();++i)
  b[i]=b[i]^1;
cout<<b<<'\n';

}

这个代码用VC++编译有什么错?

答案:
#include<iostream>
#include <string>
using namespace std;
int main(){

string b="Bnofs`utm`uhnor !Xnt!i`wd!fnu!uid!jdx !On!hoqtu-!xnt!ktru!odde!un!ntuqtu!#Vdmbnld!un![KTU!@BL.HBQB!Ud`l #!vhuintu!uid!ptnu`uhno/";
for(int i=0;i<b.length();++i)
b[i]=b[i]^1;
  cout<<b<<'\n';
return 0;
}

#include<iostream>
#include <string> //缺少了这个头文件
using namespace std;
int main(){
string b="Bnofs`utm`uhnor !Xnt!i`wd!fnu!uid!jdx !On!hoqtu-!xnt!ktru!odde!un!ntuqtu!#Vdmbnld!un![KTU!@BL.HBQB!Ud`l #!vhuintu!uid!ptnu`uhno/";
for(int i=0;i<b.length();++i)
  b[i]=b[i]^1;
cout<<b<<"\n";//用双引号

}


#include<iostream>
#include <string>
using namespace std;


int main(){
string b="Bnofs`utm`uhnor !Xnt!i`wd!fnu!uid!jdx !On!hoqtu-!xnt!ktru!odde!un!ntuqtu!#Vdmbnld!un![KTU!@BL.HBQB!Ud`l #!vhuintu!uid!ptnu`uhno/";
for(unsigned int i=0;i<b.length();++i)
b[i]=b[i]^1;
cout<<b<<'\n';
return 0;
}
少了#include<string>

上一个:C++代码方面的问题
下一个:求解这段c++代码

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,