#include <iostream>
using namespace std;
int main()
{
int n;
cin >> n;
int* p = new int;
for (int i = 0;i < n;i++)
{
cin >> *(p+i);
}
int i=n;
cin>>*(p+i);
while (*(p+i)!=0)
{
i++;
cin>>*(p+i);
}
int g=0, bad = 0;
for(n=0;n<=i;n++){
if (*(p+n) > 0) g++;
else if (*(p+n) < 0) bad++;
}
delete p;
cout << "大于0的有: " << g <<"个"<< endl << "小于0的有:" << bad;
return 0;
}
动态分配数组
于 2024-09-05 12:17:53 首次发布