我需要从命令行获取整数的列和行作为输入。这就是我到目前为止所拥有的。我只是在我的数组中放了一些随机值来检查它是否工作
14 int main(int argc, char *argv[])
15 {
16
17 int random_number;//used for random number
18 int row, cols;//command line ARGUMENT VARIABLES
19
20 //this section will create random numbers
21 srand (time(NULL));
22 random_number = rand() % 100;// 0 to 99
23 cout << random_number << endl;
24
25 //command line argument
26 cout << "there are " << argc << " arguments." << endl;
27 for (int narg = 0; narg < argc; narg++)
28 {
29 cout << narg << " " << argv[narg] << endl;
30 }
31
32 //this section is my array
33 int print_array[2][2] = {{1,2}, {3,4}};
34
35 for (int row = 0; row < 2; row++)
36 {
37 for(int column = 0; column < 2; column++)
38 {
39 cout << print_array[row][column] << " ";
40 }
41 cout << endl;
42 }