c++如何实现以组合键Ctrl+Z或人数>30结束输入

#include
#include
using namespace std;
class Student{
public:
void setData(char *no,char *na,int sco);
~Student();
static int getSum();
static int getCount();
static double calAverage();
void show();
static void showStaticData();
private:
char *stuNo;
char *name;
int score;
static int sum;
static int count;
//static int ave;
};
void Student::setData(char *no,char *na,int sco)
{

stuNo=new char[strlen(no)+1];
name=new char[strlen(na)+1];
strcpy(stuNo,no);
strcpy(name,na);
score=sco;
sum+=score;
count++;
}
Student::~Student()
{
delete []name;
delete []stuNo;
count--;
sum-=score;
// ave=sum/count;
}
int Student::getSum()
{
return sum;
}
int Student::getCount()
{
return count;
}
void Student::show()
{
cout<<"创建对象前,学生总人数、总分为:"< cout cout cout }
void Student::showStaticData()
{
cout cout }
int Student::count=0;
int Student::sum=0;
int main()
{
char *no,*na;
int sco;
cin>>no>>na>>sco;
Student stu[30];
while((cin>>no>>na>>sco)&&Student::getCount()<30)
{
stu[Student::getCount()].setData(no,na,sco);

}
return 0;
}

ctrl+z是eof
可以用
while (1)
{
if (scanf("%d", &input) == EOF) break;
if (input > 30) break;
...
}

同学,一个学校的?while (cin >> no >> na >> sco)
{
s[i].setdata(no, na, sco);

    n++;
    i++;
    if(n>29)
    {
        break;
    }

}
cout << "创建对象前,学生总人数、总分为:" << endl;
cout << "现在有0人,总分为:0" << endl;
cout << "学生成绩信息:" << endl;
for (i = 0; i <n; i++)
{
s[i].show();
}
s[i].showstaticdata();
s[i].calaverage();
不用特意写ctrl+z的函数,这相当于只输入一个元素,不满足3个元素它就自己跳出了

while(cin >> a >> b) {
.......
}