用C++编程,需要用CMD窗口显示结果,可CMD窗口闪一下就退出了,如何让CMD窗口一直显示不退出?
操作系统是Win7,C++版本2008的,代码如下//Initializingmultidimensionalarrays.#include<iostream>using...
操作系统是Win7,C++版本2008的,代码如下
// Initializing multidimensional arrays.
#include < iostream >
using namespace std;
void printArray( const int [][ 3 ] ); // propotype
const int rows = 2;
const int columns = 3;
int main()
{
int array1[ rows ][ columns ] = { { 1, 2, 3 }, { 4, 5, 6 } };
int array2[ rows ][ columns ] = { 1, 2, 3, 4, 5 };
int array3[ rows ][ columns ] = { { 1, 2 }, { 4 } };
cout << " values in array1 by row are:" << endl;
printArray( array1 );
cout << "\nValues in array2 by row are:" << endl;
printArray( array2 );
cout << "\nValues in array3 by row are:" << endl;
printArray( array3 );
} // end main
//output array with two rows and three columns
void printArray( const int a[][ columns ] )
{
// loop through array's rows
for( int i = 0; i < rows; i++ )
{
// loop through array's rows
for( int j = 0; j < columns; j++ )
cout << a[ i ][ j ] << ' ';
cout << endl; // start new line of output
} // end outer for
} // end function printArray 展开
// Initializing multidimensional arrays.
#include < iostream >
using namespace std;
void printArray( const int [][ 3 ] ); // propotype
const int rows = 2;
const int columns = 3;
int main()
{
int array1[ rows ][ columns ] = { { 1, 2, 3 }, { 4, 5, 6 } };
int array2[ rows ][ columns ] = { 1, 2, 3, 4, 5 };
int array3[ rows ][ columns ] = { { 1, 2 }, { 4 } };
cout << " values in array1 by row are:" << endl;
printArray( array1 );
cout << "\nValues in array2 by row are:" << endl;
printArray( array2 );
cout << "\nValues in array3 by row are:" << endl;
printArray( array3 );
} // end main
//output array with two rows and three columns
void printArray( const int a[][ columns ] )
{
// loop through array's rows
for( int i = 0; i < rows; i++ )
{
// loop through array's rows
for( int j = 0; j < columns; j++ )
cout << a[ i ][ j ] << ' ';
cout << endl; // start new line of output
} // end outer for
} // end function printArray 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询