#include
void main()
{
float Temp,zheng = 0,fu = 0;
int i,zeroo = 0;
for(i=1;i<=10;i++)
{
scanf("%f",&Temp);
if(Temp>0)
zheng++;
if(Temp<0)
fu++;
if(Temp==0)
zeroo++;
}
printf("正数有:%g,负数有:%g,零有:%d。",zheng,fu,zeroo); /* %g,舍弃无意义的小数部分 */
}
#include
int main()
{
int count=10;
int n;
int pn=0, sn=0, zn=0;
while (count--)
{
scanf("%d", &n);
if (n >0)
pn++;
else if (n==0)
zn++;
else
sn++;
}
printf("正数:%d\t负数:%d\t零:%d\n", pn, sn, zn);
return 0;
}
#include
using namespace std;
int main()
{
cout << "请输入十个数:" << endl;
int i;
int num[10];
int posCount = 0;
int negCount = 0;
int zeroCount = 0;
for( i=0; i<10; i++ )
{
cin >> num[i];
if( num[i] > 0 )
posCount++;
else if( num[i] < 0 )
negCount++;
else
zeroCount++;
}
cout << "正数有 " << posCount << " 个\n"
<< "负数有 " << negCount << " 个\n"
<< "零有 " << zeroCount << " 个\n";
system("pause");
return 0;
}
//---------------------------------------------------------------------------
#include
int main(void)
{
int i,a,d=0,u=0,z=0;
for (i = 0; i < 10; i++) {
scanf("%d",&a);
if (!a) z++;
else if (a>0) u++;
else d++;
}
printf("正整数个数:%d\n零的个数:%d\n负整数个数:%d\n",u,z,d);
return 0;
}
//---------------------------------------------------------------------------