Playground
#include <iostream> #include <vector> using namespace std; int main() { //edna dimenzija vector<string> v1(3, "ABC"); //v1={"ABC", "ABC", "ABC"); //dve dimenzii (zabelezhete '> >') vector<vector<int> > v2(3); //v2={{}, {}, {}) v2[0].push_back(1); //v2={{1}, {}, {}) v2[0].push_back(2); //v2={{1, 2}, {}, {}) v2[1].push_back(3); //v2={{1, 2}, {3}, {}) v2[2].push_back(4); //v2={{1, 2}, {3}, {4}) v2[2].push_back(5); //v2={{1, 2}, {3}, {4, 5}) v2[2].push_back(6); //v2={{1, 2}, {3}, {4, 5, 6}) cout << v2[0][0] + v2[0][1] << endl; //pechati '3' (1+2) cout << v2[1][0] << endl; //pechati '3' (3) cout << v2[2][0] + v2[2][1] + v2[2][2] << endl; //pechati '15' (4+5+6) cout << v2[0].size() << endl; //pechati '2' cout << v2[1].size() << endl; //pechati '1' cout << v2[2].size() << endl; //pechati '3' return 0; }
Input data
Program output
no input
Execute
Language: ????????? | Memory: ???? KB | Time: ??? ms
Nothing has been executed, yet!