【发布时间】:2016-08-11 09:59:09
【问题描述】:
我的代码输出在function2() 上方显示function1()。有没有办法编写代码,以便输出在function2() 旁边(如并排)显示function1()?
下面是我的代码的 sn-p:
#include <iostream>
using namespace std;
void function1()
{
int i;
int array[5] = {5, 5, 5, 5, 5};
cout << " -1-2-3-4-5-" << endl;
cout << " |";
for (i = 0; i < 5; ++i)
cout << array[i] << "|";
cout << endl;
}
void function2()
{
int i;
char array[5] = {'A', 'A', 'A', 'A', 'A'};
cout << " -1-2-3-4-5-" << endl;
cout << " |";
for (i = 0; i < 5; ++i)
cout << array[i] << "|";
cout << endl;
}
int main()
{
function1();
function2();
return 0;
}
【问题讨论】:
-
不要在
coutoffunction1()中使用endl -
嗯,我猜他想要一个像 5
-
@Anedar 完全正确。两个函数的第一行、第二行等将彼此相邻。