我正在尝试创建一个数组,该数组接受用户输入并在 99 99 处中断,但多维数组不会停止接受输入值。另一个问题是让值显示在视觉表示下方的网格上。如果需要更多说明,请告诉我。
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
srand(time(0));
int organisms[22][22];
int rows,
columns;
int input[22][22];
int *output = new int[];
//filling array
for(int i=0;i<22;i++)
{
for(int j=0;j<22;j++)
{
organisms[i][j]=0;
}
}
//column output
cout<<"\t\t\t\t\t\t\t\t\t\t\t\t\tColumn\n\n";
for(columns=1;columns<21;columns++)
{
cout<<"\t"<<columns;
}
cout<<"\n\n\n";
//Row and data output
for(int i=0;i<20;i++)
{
cout<<"Row "<<i+1<<"\t";
for(int j=0;j<20;j++)
{
cout<<organisms[i][j]<<"\t";
}
cout<<endl;
}
cout<<"\n\n\n";
cout<<"Enter each cell in first colony use row space column Enter format, 3 4, for example.\nEnter 99 99 to end entries.\n";
//input of values
cin.ignore(4);
int m=0;
do
{
cin>>input[m][m];
m++;
if(input[m][m]!=99,99)
break;
}while(m<20);
/*
while(input[m][m]!=99,99)
{
cin>>input[m][m];
m++;
}
/*
for(int m=0;m<INT_MAX;m++)
{
cin>>input[m][m];
if(input[m][m]==99)
break;
}
*/
//input array indexing
//output array
cout<<"\n\n\n";
cout<<"\t\t\t\t\t\t\t\t\t\t\t\t\tColumn\n\n";
for(columns=1;columns<21;columns++)
{
cout<<"\t"<<columns;
}
cout<<"\n\n\n";
for(int i=0;i<20;i++)
{
cout<<"Row "<<i+1<<"\t";
cout<<endl;
for(int n=0;n<20;n++)
{
cout<<input[i][n]<<"\t";
}
cout<<endl;
}
cin.get();
cin.get();
return 0;
}