why is this happening, there shouldn't be any space between 10 and the input
The input is 'Potato' and the output is showing after 10.
这是真正的代码-
#include <iostream>
using namespace std;
int main()
{
int a = 5;
int b = 6;
cout << endl <<a+b;
for (int i = 0; i <= 10; ++i) {
cout << endl << " Number " << i;
}
string name;
cin >> name;
cout << endl << endl << name;
return 0;
}
1条答案
按热度按时间fruv7luv1#
我不知道你读什么来做这些事情,因为:
1.没有人这样做:
cout << endl << " Number " << i;
。你应该学会像这样使用它:cout << " Number " << i<<endl;
,如果你特别想在第一行加一个换行符,你可以只在第一行加cout<<endl;
或cout<<"\n";
1.根据我对你问题的理解,我认为你没有抓住重点。在
" Number "
之间有一个空格,您可能应该将其更改为"Number "
1.您明确地、明确地接受了输入,并在最后打印了'potato'的输入。本部分:
在这部分之后:
很明显,您输入的文本“potato”在10之后打印。
这段代码可以帮助你:
这段代码显示了如下输出:
我希望这对你有帮助!!!