显示阵列排列

时间:2015-04-05 03:04:46

标签: c++

我想显示一个数组排列,其中包含#行和#列的输入,并且还在输入间隔插入一个符号。到目前为止我有这个但是我的输出一次只显示1行,直到输入被按下因为选择了多少行。我还没有开始间隔符号插入。任何有关这方面的帮助将不胜感激。

#include <iostream>

using namespace std;

int rows = 0, columns = 0,intervals= 0;
void Display(int rows = 0, int columns = 0, int intervals = 0);

int main()
{

    cout << "Enter number of rows: ";
    cin >> rows;

    cout << "Enter the number of columns: ";
    cin >> columns;

    cout << "Enter the number of the question mark interval: ";
    cin >> intervals;
    cout << "\n";

    cout << "How many rows do you want? " << rows << "\n";
    cout << "How many columns do you want? " << columns << "\n";
    cout << "How far between question marks? " << intervals << "\n";

    Display(rows, columns, intervals);

    return(0);
    system("pause");
}

void Display(int rows, int columns, int intervals)
{
    for (int y = 1; y <= rows; y++) 
    {
        for (int x = 1; x <= columns; x++) {
            cout << intervals;
        }
        cout << endl;
        system("pause");
    }
}

1 个答案:

答案 0 :(得分:0)

在循环外使用system("pause") -

void Display(int rows, int columns, int intervals)
{
    for (int y = 1; y <= rows; y++)
    {
        for (int x = 1; x <= columns; x++) {
            cout << intervals;
        }
        cout << endl;
    }
    system("pause");
}