哪为高手帮我做做题目啊~~~~救命

[复制链接]
查看1776 | 回复4 | 2007-1-24 16:53:00 | 显示全部楼层 |阅读模式

#stdio.h

#string.h

class CfileArray

{

public:

CFileArray(ch* ar*filename);

ch* ar& operator[] (int index);

virtual ~CFileArray();

void Apply();

int filelen;

private:

ch* ar *bin;

FILE *fp;

ch* ar file[255];

};

CFileArray::CFileArray(ch* ar *filename)

{

strcpy(file, filename);

bin = NULL;

fp = fopen(file, "rb+");

if(!fp)

return;

fseek(fp, 0, SEEK_END);

filelen = ftell(fp);
bin = new ch* ar[filelen];

if(!bin)

return;

fseek(fp, 0, SEEK_SET);

fread(bin, filelen, 1, fp);

fclose(fp);

CFileArray::~CFileArray()
{

Apply();

if(bin)

del e*te []bin;

}

void CFileArray::Apply()

{

fp = fopen(file, "wb+");

fwrite(bin, filelen, 1, fp);

fclose(fp);

}

ch* ar& CFileArray::operator[] (int index)

{

return bin[index];

}

void main()

{

CFileArray f("test.dat");

f[0] = 't';

f[1] = 'e';

for(int i=0;i<f.filelen;i++)

{

printf("%c", f);

}

}

#include <stdio.h>

#include <string.h>

#define KEYWORD_IN "keyword.in"

#define TEXT_IN "text.in"

#define KEYWORD_OUT "keyword.out"

#define NOT_KEYWORD_OUT "not_keyword.out"

template <>

class hash<string>

{

hash<const ch* ar *> hash_func;

public:

size_t operator()(const string &str) const

{

return hash_func(str.c_str());

}

};

typedef hash_set<string> hash_set_t;

typedef hash_map<string, int> hash_map_t;

int main()

{

hash_map_t hm;

hash_set_t hs;

string str_in;

ifstream keyword_in(KEYWORD_IN);

while (keyword_in)

{

keyword_in >> str_in;

hs.in se*rt(str_in);

}

ifstream text_in(TEXT_IN);

while (text_in)

{

text_in >> str_in;

if (hm.find(str_in) == hm.end())

hm[str_in] = 0;

hm[str_in]++;

}

ofstream keyword_out(KEYWORD_OUT);

ofstream not_keyword_out(NOT_KEYWORD_OUT);

for (hash_map_t::iterator it = hm.begin(); it != hm.end(); it++)

{

if (hs.co u* nt(it->first))

{

keyword_out << it->first << " " << it->second << endl;

}

else

{

not_keyword_out << it->first << " " << it->second << endl;

}

}

return 0;

}

huangzhenm | 2007-1-24 18:53:00 | 显示全部楼层
kan bu dong a
zywplc | 2007-1-25 16:17:00 | 显示全部楼层

不懂!

2006dcq | 2007-3-8 14:04:00 | 显示全部楼层
你是让大家给你作什么?是程序改错?
PENGLIZHEN | 2007-5-11 20:16:00 | 显示全部楼层
谁给你出的啊
您需要登录后才可以回帖 登录 | 注册哦

本版积分规则