#include
#include
#include
using namespace std;
class danci
{
public:
string name;
int num;
danci(){num=0;name="";};
};
void readfile(danci*&inchar,int &counter)
{
ifstream infile("in.txt");
if(!infile) {cout<<"cannot open!"<
{
string temp;
infile>>temp;
int i=0;
for( ;i
if(temp==inchar[i].name) { inchar[i].num++;break;}
}
if(i==counter&&inchar[i].name!=temp)
{
inchar[counter].name=temp;
inchar[counter].num++;
counter++;
}
};
infile.close();
}
void outfile(danci*inchar,int counter)
{
ofstream outfile("out.txt");
for(int i=0;i
void main()
{
danci*inchar=new danci[1000];
int counter=0;
readfile(inchar,counter);
outfile(inchar,counter);
}上次是你问的吧,我不都告诉你了吗,难道不对吗
这个要用到哈希表