填空题 C++ 题号 #4126120 表达式cout<<’\n’还可以表示为_______。 收起答案及解析 进入在线模考 参考答案 暂无 答案解析 cout<<endl 你可能感兴趣的试题 1 有如下的程序: #include<iostream> #include<fstream> using namespace std; int main(){ char s[25]="Programming language"; ofstream f1("DATA.TXT"); f1<<"C++ Programming"; f1.close(); ifstream f2("DATA.TXT"); if(f2.good())f2>>s; f2.close(); cout<<s; return 0; } 执行上面的程序将输出。 查看解析 → 2 有如下的程序: #include<iostream> using namespace std; class AT{ friend ostream& operator<<(ostream&,AT); }at; ostream& operator<<(ostream& os,AT){return os<<'@';} int main(){ cout<<"MyHome"<<at<<"isHere.com"; return 0; } 执行上面的程序将输出。 查看解析 → 3 有如下的程序: #include<iostream> #include<cstring> using namespace std; class rev{ char * s; public: rev(const char *s){ this->s=new char[strlen(s)+1]; strcpy(this->s,s); } rev(rev &r){ s=new char[strlen(s)+1]; for(int i=0;i<strlen(r.s);i++)s[i]=r.s[strlen(r.s)-1-i]; s[stelen(r.s)]=0; } ~rev(){delete s;} friend ostream& operator<<(ostream&,const rev &); }; ostream& operator<<(ostream &os,contst rev&c){ for(int i=strlen(c.s)-1;i>=0;i--)os<<c.s[i]; return 0; } int mian(){ char *p="Hello,world!"; rev hey("hay!"); cout<<rev(p)<<endl; cout<<rev(hay); return 0; } 执行上面的程序将输出。 查看解析 →