PLC论坛-全力打造可编程控制器专业技术论坛

 找回密码
 注册哦

QQ登录

只需一步,快速开始

微信扫码登录

查看: 1716|回复: 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;

}

回复

使用道具 举报

发表于 2007-1-24 18:53:00 | 显示全部楼层
kan bu dong a
回复 支持 反对

使用道具 举报

发表于 2007-1-25 16:17:00 | 显示全部楼层

不懂!

回复 支持 反对

使用道具 举报

发表于 2007-3-8 14:04:00 | 显示全部楼层
你是让大家给你作什么?是程序改错?
回复 支持 反对

使用道具 举报

发表于 2007-5-11 20:16:00 | 显示全部楼层
谁给你出的啊
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册哦

本版积分规则

QQ|小黑屋|手机版|Archiver|PLC技术网-PLC论坛 ( 粤ICP备17165530号 )|网站地图

GMT+8, 2024-4-28 01:19 , Processed in 0.053248 second(s), 25 queries .

快速回复 返回顶部 返回列表