これが少しばかげた質問である場合は申し訳ありません。
これが私のコードです:
#include<iostream>
using namespace std;
int main()
{
int columns, rows;
char **map;
cin>>columns;
cin>>rows;
/*creats array of pointers rows tall*/
map = new char*[rows];
/*creats array of chars columns tall*/
for(int i=0; i<rows; i++)
map[i] = new char[columns];
//populate map with input
map[0][0] = cin.get();
for(int j=0; j<rows; j++)
for(int i=0; i<columns; i++)
{
if (cin.peek() == '\n')
cin.ignore(256, '\n');
else
map[j][i] = cin.get();
}
//DISPLAY
cout<<endl;
for(int j=0; j<rows; j++)
{
for(int i=0; i<columns; i++)
{
cout<<map[j][i];
}
}
return 0;
}
ユーザーは次のように入力します。
7 4
#######
#S# #
# #E#
#######
と出力したいと思います。しかし、私のものは次のようになります:
#######
#S#
## #
E#####
何かご意見は?