0
I'a试图执行一个算法,我要由用户为2D矢量输入元件,使得我有一个这样的元件:输入元件
reference 1:
1 2 3
3 2 1
1 2 3
所以想知道如何元素的push_back成2D矢量
我的问题就在这里:
std::vector<vector<int>> d;
//std::vector<int> d;
cout<<"Enter the N number of ship and port:"<<endl;
cin>>in;
cout<<"\Enter preference etc..:\n";
for(i=0; i<in; i++){
cout<<"ship"<<i+1<<":"<<' ';
for(j=0; j<in; j++){
cin>>temp;
d.push_back(temp);// I don't know how to push_back here!!
}
}
谢谢,关于印刷品,如果我尝试这样做(i = 0; i
你忘了把一个新的行符号'cout << d [i] << std :: endl' – gdlmx
ooooh yes thaaaank you :))) –