所以输出应该是这样的:
This is a Heading blah
---------------------
1st - First
2nd - Second
3rd - Third
我将在下面发布我的代码,但在你判断之前请注意这是我第二天学习C ++(任何编程语言)。我可能看起来像个白痴,但感谢先进的任何帮助。
char place = '1';
string firstPlace = "First";
char place = '1';
string secondPlace = "Second";
char place = '1';
string thirdPlace = "Third";
cout << "This is a Heading blah" << endl;
cout << "---------------------" << endl;
cout << "1st - " << firstPlace;
cout <<'\n';
cout << "2nd - " << secondPlace;
cout <<'\n';
cout << "1st - " << thirdPlace;
cout <<'\n';
答案 0 :(得分:1)
首先,您需要包含std函数的头文件:
#include <iostream> // cout
#include <string> // string
using namespace std; // or std::cout
和地点被宣布超过1次:
char place = '1';
string firstPlace = "First";
所以,代码应该是:
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char const *argv[])
{
char place = '1';
string firstPlace = "First";
string secondPlace = "Second";
string thirdPlace = "Third";
cout << "This is a Heading blah" << endl;
cout << "---------------------" << endl;
cout << "1st - " << firstPlace;
cout <<'\n';
cout << "2nd - " << secondPlace;
cout <<'\n';
cout << "1st - " << thirdPlace;
cout <<'\n';
return 0;
}