![]() |
#2
lintaoyn2013-03-10 15:31
|
#include<iostream>
using namespace std;
int main()
{
int *p,i,num,positive=0,negative=0;
int p=new int[20];
if (!p)
{
cout<<"number error.\n";
return 1;
}
do{
cin>>num;
}while(num>20||num<1);
for(i=0;i<num;i++)
{
cin>>*(p+i);
if (*(p+i)>0)
positive++;
if (*(p+i)<0)
negative++;
}
delete []p;
cout<<"There are "<<num<<" figures,\n";
cout<<positive<<" of them are positive numbers,\n";
cout<<negative<<" of them are negatives.\n";
return 0;
}
[ 本帖最后由 随着心飞翔 于 2013-3-10 15:25 编辑 ]