Thronds
unread,Oct 21, 2008, 12:51:50 AM10/21/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to TopLanguage
1. 某计算机系统只有以下原子操作:
赋值
+1运算
循环 只能是固定次数的循环
只操作0和正整数
不会溢出
用伪代码实现加法,减法,乘法和除法运算。
2.找出下面程序的错误,如何修正。
#include <vector>
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
class Test
{
public:
string s;
};
int main()
{
Test *t= new Test[3];
ofstream output("file",ofstream::binary);
t[0].s="hello";
t[1].s="world";
t[2].s="!";
output.write((char* )t,3*sizeof(Test));
output.close();
delete[] t;
ifstream input("file",ifstream::binary);
Test in[3];
input.read((char* )in,3*sizeof(Test));
input.close();
cout<<in[0].s<<in[1].s<<in[2].s<<endl;
return 0;
}
(1)找出程序中的错误,如何修正
(2)stl中string的内存管理方式
(3)用C实现一个可变长字符串,要求方便高效。
3.大型系统多采用数据库存储数据,但访问量很大,所以要用cache,又因为数据规模也很大,所以用分布式管理。有一个查询语句 select
pid uid content from ltb where fid = FID & power = POWER order by pid.查
询的差别就是fid和power的不同。根据上面信息优化上面的查询语句。
现在请设计一个方案用来实现下面两个目标:
1).可实现查询,更新命令
2).能够高效地查询更新
请给出:
1).核心的数据结构和算法
2).描述存储方案
3).给出一个查询和更新过程。