+ 1
Как передать размер массива в функцию? How do I pass array sizes to a function without "const"?
https://code.sololearn.com/cFVAEBT72P21/?ref=app Если я объявляю переменные size_line и size_column(кол-во строк и столбцов) в теле функции main то программа не работает, единственное, что придумал, так это прописать их как константы в самом начале. Моя задача вводить эти две переменные с клавиатуры и заполнять массив случайными значениями. Большое спасибо :3
18 Réponses
+ 2
Please write your question in English if you want you can use Google translate
+ 2
I will send you code later
+ 1
I need to enter variables (size_line,size_column) using the keyboard
+ 1
I can't do it in function
+ 1
If you are a problem
Write a code then send me the link like that i corrige you code
+ 1
this is not what I need
+ 1
Yes i am just look you code
+ 1
the array does not have a fixed size.I want to enter new size values each time using the keyboard
+ 1
thanks a lot! isn't it possible to create a dynamic two-dimensional array and pass it to the function using the same pointers?
0
In c++
Use
 cin >> size_line >> size_column;
0
#include <iostream>
using namespace std;
const int size_line=5 ;
const int size_column=5 ;
void FillArrRandomNum(int arr[size_line ][size_column ],int size_line,int size_column){
    for(int line=0;line<size_line;line++){
    for(int column=0;column<size_column;column++){
    arr[line][column]=30+rand()%31; 
    cout<<arr[line][column]<<" ";
    }
    cout<<endl;
    }
    };
    
    int SearchMaxNumber(int arr[size_line ][size_column ],int size_line,int size_column){
    int max=arr[0][0];
    for(int line=0;line<size_line;line++){
        for(int column=0;column<size_column;column++){
        
       if(arr[line][column]>max){
         max=arr[line][column];
     }
     }   
     }
     return max;
     };
     
     int SearchMinNumber(int arr[size_line ][size_column ],int size_line,int size_column){
    int min=arr[0][0];
    for(int line=0;line<size_line;line++){
        for(int column=0;column<size_column;column++){
        
       if(arr[line][column]<min){
         min=arr[line][column];
     }
0
#include <iostream>
using namespace std;
int main() {
    
    int size_line, size_column;
    cin >> size_line;
    cin >> size_column;
    
    cout << "Line Size: " << size_line  << endl;
    cout << "Column size: " << size_column << endl;
    return 0;
}



