一份笔试题

2011珠海金山办公软件WPS Office(JAVA笔试题)
                   

1. 编程计算某给定的整数在用17进制来表示时含有多少个1。
例:十进制整数18用17进制表示为0x11,含有2个1。


2. 集合合并:
给定一些字符集合,形式如:
{a b c},
{b d},
{e f},
{g},
{d h}
要求将其中交集不为空的集合合并,合并完成后的所有集合之间无交集,例如上例应
输出:
{a b c d h},
{e f},
{g}
请画出算法流程图。

3  实现一个可以Undo/Redo的链表, 链表的结点中存储整数, 支持的操作包括:
* 插入1个数字: insertAfter(Node pos, int val)
* 删除多个连续的结点: remove(Node start, Node end)
* 修改1个结点的值: modify(Node node, int val)
* 以及对上述三个操作的撤消和重新执行
* 撤消:undo(),掉用此方法可以撤消插入,删除和修改,且可以连续撤消
* 重新执行:Redo(),调用此方法可以重新执行被撤消和操作,且可以连续调用

如:一系列的操作执行如下:
Insert,insert,remove,undo,undo,modify,insert,undo,undo,redo,redo 等价于 insert,modify,insert

请写出主要的数据结构定义。
写出这5个操作的伪代码实现



4. 写出程序的输出结果
class insect{
int i=9;
int j;
insect(){
prt("i= "+i+" j="+j);
j=39;
}
static int x1=prt("static insect x1 initialized");
static int prt(String s){
System.out.println(s);
return 47;
}
}
public class Wps extends insect{
int k=prt("wps be initialized");
Wps(){
prt("k="+k);
prt("j="+j);
}
static int x2=prt("static wps x2 initialized");
static int prt(String s){
System.out.println(s);
return 63;
}

public static void main(String[] args){
    insect.prt("initialized constructor");
    Wps w=new Wps();
    }
}
答:

供大家参考交流!

猜你喜欢

转载自lwazl1314.iteye.com/blog/1244806