所以,我是学习 C++ 的“noob”,我刚刚制作了这段代码,它显示了我的用户名和一种矩形。我知道这不是很好的代码,但我喜欢它!我只是想看看是否有人可以让它变得更好并给我一些有用的提示? (是的,我使用的是 Dev-C++) 在此先感谢,:)(我不知道为什么这个问题被关闭了,但请“投票”我想我是对的)
代码:
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
cout << "#################################" << endl;
cout << "## ##" << endl;
cout << "## ##" << endl;
cout << "## ##" << endl;
cout << setw(20) << setiosflags(ios::left) << "## Hi! My name's Rale, ##" << endl;
cout << setw(20) << setiosflags(ios::left) << "## 14yo guy who likes C++! ##" << endl;
cout << "## ##" << endl;
cout << "## ##" << endl;
cout << setw(33) << setiosflags(ios::left) << "## ##" << endl;
cout << setw(33) << setiosflags(ios::right) << ## ##" << endl;
cout << "#################################" << endl << endl;
cout << "As you can see, I've made this in just a couple of minutes, with C++! YAY!" << endl << endl;
system("pause");
return 0;
}
答案 0 :(得分:-2)
注意你的第一行,你需要在你的包含周围加上 <>
休息很好,下面的代码也很好
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
cout << "#################################" << endl;
cout << "## ##" << endl;
cout << "## ##" << endl;
cout << "## ##" << endl;
cout << setw(20) << setiosflags(ios::left) << "## Hi! My name's Rastko, ##" << endl;
cout << setw(20) << setiosflags(ios::left) << "## 14yo guy who likes C++! ##" << endl;
cout << "## ##" << endl;
cout << "## ##" << endl;
cout << setw(33) << setiosflags(ios::left) << "## ##" << endl;
cout << setw(33) << setiosflags(ios::right) << "## ##" << endl;
cout << "#################################" << endl << endl;
cout << "As you can see, I've made this in just a couple of minutes, with C++! YAY!" << endl << endl;
return 0;
}