📄 e_4_1_182_刘星辰.cpp
字号:
#include<iostream.h>
class CheckINT
{
public:
CheckINT();
void Check(int);
void show();
private:
int positiveCount;
int negativeCount;
int zeroCount;
};
CheckINT::CheckINT()
{
positiveCount=0;
negativeCount=0;
zeroCount=0;
}
void CheckINT::Check(int n)
{
if (n>0)
positiveCount=positiveCount+1;
if (n<0)
negativeCount=negativeCount+1;
if (n==0)
zeroCount=zeroCount+1;
}
void CheckINT::show()
{
int s;
s=positiveCount+negativeCount+zeroCount;
cout<<"所判别的整数共"<<s<<"个"<<endl;
cout<<"其中正整数"<<positiveCount<<"个,";
cout<<"负整数"<<negativeCount<<"个,";
cout<<"零"<<zeroCount<<"个。"<<endl;
}
void CheckInputValue(int in[], int num, CheckINT &checker)
{
int k;
for(k=0;k<num;k++)
checker.Check(in[k]);
}
main()
{
int sum,i;
int number[100];
CheckINT N;
cout<<"请输入所要判别的整数的总数为:";
cin>>sum;
cout<<"请输入所要判别的整数:"<<endl;
for(i=0;i<sum;i++)
{
cin>>number[i];
}
CheckInputValue(number,sum,N);
N.show();
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -