日期:2014-05-18  浏览次数:20676 次

月薪4000的笔试题目
题目1:实现一个用户订阅邮件的场景
描述:
1) 用户使用邮件来注册
2) 系统在5分钟内发送激活链接的邮件
3) 用户点击邮件后,激活用户,结束
4) 管理员可以查看已经激活和未激活的用户列表
5) 无需实现用户登录

题目2:有一个表product( Description nvarchar (1000), Order int ) ,表中有5条记录,每条记录的Description字段都有内容,内容的字符数量有长有短。要求实现一个网页,以一个列表显示product的Description,要求按照Order来排序, 列表的宽度为200,高度为150,超长度的Description自动折行,5条记录如果总共的高度超过150,那么只显示到150高度范围的内容,其他内容忽略掉,并且最后一行加上…表示,

例如:

其中,1和2都是Order的值,后面就是Description的值。


题目3:有一个表 ordertable(price money,id int), 表中有50条记录,其中price中数据是不规则的,要求用一条查询语句取出price的和最大的连续5条记录
 例如:
1 10.00
2 5.00
3 6.00
4 8.00
5 1.00
6 20.00
7 60.00
8 4.00
9 3.00
10 2.00
11 80.00
12 120.00
13 1.00

和最大的连续5条记录就是
8 4.00
9 3.00
10 2.00
11 80.00
12 120.00

 
要求:1、使用asp.net 2.0
 2、使用C#语言
3、使用Sql Server 2000数据库
4、提交源代码和数据库脚本
请高手帮忙```急 在线等 明天早上8点要交呢 先谢谢各位大虾了


------解决方案--------------------
题目1用数据库来保存激活码,并且加上是否激活标志符
题目2比较变态,Description nvarchar (1000),没这么定义字段的。先计算好高度150的表格能放多少个字,5条记录总文字数超出就用。。。表示
题目3 select top5 * from ordertable where id>(
select id from (select id, price+(select price+(select price+(select price+(select price+ from ordertable as o5 where o5.id=o4.id+1) from ordertable as o4 where o4.id=o3.id+1) from ordertable as o3 where o3.id=o2.id+1) from ordertable as o2 where o2.id=o1.id+1) as sumprice from ordertable as o1 order by sumprice desc))
------解决方案--------------------
select top 5 * from ordertable where id >=( 
select id from 
(select top 1 id, price+(select price+(select price+(select price+(select price from ordertable o5 where o5.id=o4.id+1) from ordertable o4 where o4.id=o3.id+1) from ordertable o3 where o3.id=o2.id+1) from ordertable o2 where o2.id=o1.id+1) as sumprice from ordertable o1 order by sumprice desc 
) #
)
------解决方案--------------------
1.zyowe应该可以吧,没试过
2.好像有个word-break,over-flow:hidden;
3.select *
from ordertable C
where abs(C.id-(
select top 1 id
from ordertable A
where id>=5
order by (select sum(price) from ordertable B
where abs(B.id-A.id)<=2) desc))<=2

------解决方案--------------------
感觉第一二题应该是针对网站的,但第三题有点奇怪.很少出现的逻辑.



第一题没什么难度,
第二题:第二题用CSS很容易解决(这关系到目前流行的一些DIV+CSS的设计,大部分美工也没用上),也可以直接看看200x150能放多少个字节的内容,进行限制出来.

第三题:我还真做不出来
------解决方案--------------------
第一个问题 答案 
发邮件时激活连接带上用户ID 和一个自动生成码 然后这个生成码保存在数据库中 如果需要安全 可以加密过 还有一个状态字段保持时候即或状态 注册的时候先置否 激活就根据GET传递过来的值对应用户ID和激活随机生成码 设置该用户ID的激活字段值为 是 登陆时检测 是否激活字段即可 
在激活时可以设置该ID状态为登陆状态(session) 既不需要重新登陆 
第二个问题 可以用CSS来解决,如果要用程序也可以, 计算字符个数 根据ASC 码 判断是否是全角或半角 如果一个全角就=2个半角 根据最后的半角个数 截断相应的文本字符 如果超过则再截去4个半角字符 然后用...代替 如果相等则不需要截断
第三个问题 
select top 5 * from ordertable where id<=(select top 1 id from ordertable order by price desc) order by id desc
------解决方案--------------------
第二题的代码

 public string CutWords(string STR,int Size)
{
string a;
int bits = 0;
string restr="";
for (int i = 0; i < STR.Length; i++)
{
a = STR.Substring(i, 1);
bits+=System.Text.Encoding.Default.GetByteCount(a);
restr += a;
if (bits>Size-2)
break;


}
if (restr.Length > 3)
{
if (restr.Length < STR.Length)