Return array in a function

后端 未结 19 2295
清酒与你
清酒与你 2020-11-22 05:23

I have an array int arr[5] that is passed to a function fillarr(int arr[]):

int fillarr(int arr[])
{
    for(...);
    return arr;
         


        
19条回答
  •  盖世英雄少女心
    2020-11-22 05:51

    Here's a full example of this kind of problem to solve

    #include 
    using namespace std;
    int* solve(int brr[],int n)
    {
    sort(brr,brr+n);
    return brr;
    }
    
    int main()
    {
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i>arr[i];
    }
    int *a=solve(arr,n);
    for(int i=0;i

提交回复
热议问题