#include<iostream>
using namespace std;
void main()
{
int i,a=0,b=0,n=0,no[20],*ptr;
do
cin>>no[n];
while(++n);
ptr=new int[20];
int sum(ptr,int i)
{
int j=0;
while(j<=i)
{
if(*ptr>0)
{
++a;
++j;
++ptr;
}
else if (*ptr<0)
{
++b;
++j;
++ptr;
};
}
int sum(no,n);
cout<<"the number of positive is"<<a<<endl;
cout<<"the number of negative is "<<b<<endl;
delete []ptr;
}
}
输入20个数,统计正数个数和负数个数,帮忙解决一下!
最新推荐文章于 2022-09-12 09:19:35 发布