include <iostream>
#include <fstream>
using namespace std;
const int MAX = 12;
int len = 0;
class Stack
{
private:
int *Item;
int top;
public:
Stack();
~Stack();
void Push(int i);
int Pop();
bool isempty();
bool isfull();
void Peek();
int Gettop();
void Select();
};Stack A;Stack::Stack()
{
Item = new int[MAX];
top = -1;
}Stack::~Stack()
{
delete [] Item;
}bool Stack::isfull()
{
return(top == MAX-1);
}bool Stack::isempty()
{
return(top == -1);
}int Stack::Gettop()
{
return top;
}void Stack::Peek()
 {
  if(isempty())
  {
      cout<<"栈为空!"<<endl;
  return;
  }
  int i;
  for(i = 0;i != top + 1;i++)
  {
   cout<<Item[i]<<"  ";
  }
  cout<<endl;
 }int Stack::Push(int elem)
{ for(i=1;i<n;i++)
{
cin<<elem;
if(stack.isempty())
stack.push(elem);
else if(elem!=Stack.top())
Stack.pop();
else
stack.push(elem);
}
}int Stack::Pop()
{
int Elem = 0;
if(isempty())
cout<<"栈为空!"<<endl;
else
{
Elem = Item[top];
top--;
}
return Elem;
}
void Load()
{
int i,len;
fstream fp;
int Elem[MAX];
fp.open("input.txt");
if(fp.fail())
cerr<<"打开文件失败!"<<endl;
fp>>len;
for(i = 0;i != len;i++)
{
fp>>Elem[i];
A.Push(Elem[i]);
}
fp.close();
}void Stack::Select()
{
int len = A.Gettop() + 1;
int a = 0;
int arr[20] = {0};
for(int i = 0;i != len;i++)
{
if(++arr[Item[i]] > len/2)
{
a++;
cout<<"英雄数为: "<<Item[i]<<endl;
}
}
if(!a)
cout<<"没有英雄数!"<<endl;}
void save()
{
fstream fp;
int i,j;
len = A.Gettop() + 1;
int Elem[MAX];
fp.open("input.txt",ios::out);
if(fp.fail())
cerr<<"打开文件失败!"<<endl;
fp<<len<<endl;
for(i = len - 1;i != -1;i--)
Elem[i] = A.Pop();
for(j = 0;j != len;j++)
fp<<Elem[j]<<" ";
fp.close();
}
int main()
{
Load();
A.Peek();
A.Select();
save();

return 0;
}
--------------------Configuration: 英雄树问题 - Win32 Debug--------------------
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/英雄树问题.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.