0
Follow
0
View

C++ How to solve this ah, why the error

CSP13911663120 注册会员
2023-02-28 06:17
csgp521 注册会员
2023-02-28 06:17

new and delete

int **a;
a=new int*[3];
for(int i=0;i<3;i++)
    a[i]=new int[3]; 
for(int i=0;i<3;i++)
    delete[]a[i];
delete[]a;

or replace line 6 with:
int(*a)[3] = nullptr;
a = new int[3][3];

tony88chen 注册会员
2023-02-28 06:17

It's not as hard as you think.

 #include
using namespace std;
int main()
{
    int a[9];
    int max=-1e9,min=1e9,sum=0;
    for(int i=0;i<9;i++){
        cin >> a[i];
        sum+=a[i];
        if(maxif(min>a[i])    min=a[i];
    }
    cout << "和为" << sum << endl;
    cout << "最大值为" << max << endl;
    cout << "最小值为" << min;
}

About the Author

Question Info

Publish Time
2023-02-28 06:17
Update Time
2023-02-28 06:17

Related Question