注:C++11 支持,g++ test.cpp -std=c++11
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
vector<vector<int> > board1 (10, vector<int>(10, 0));
int m = board1.size();
int n = board1[0].size();
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
cout<< board1[i][j]<<" ";
}
cout<<endl;
}
vector<vector<char> > board2 = {{'X','.','.','X'}, {'.','.','X','X'}, {'X','X','.','.'}};
m = board2.size();
n = board2[0].size();
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
cout<< board2[i][j]<<" ";
}
cout<<endl;
}
}
网友评论