帮帮看

yatming66 2011-08-26 09:53:36
哥们们 帮解答下呗 新手 分不多


1.班级表class(班级名称name,班级Id)和学生表student(学生Id,学生name,学生所在班级classId),写一条sql语句,查询出人数最多的前5个班级,不限数据库

2.写一个函数,从1到30中随机选出7个不同的数字输出(30选7机选),请写出代码或给出详细思路,不限编程语言。另外可以考虑一下如果输出的数字要求从小到大排序好,有没有比较比较简单的解决办法

3.有一个筐,筐左边一个人,筐右边一个人,左边这个人一个个向筐里面放苹果,右边这个人一个个从筐里取苹果,周而复始。写一个独立的console程序,能够自动把该场景模拟出来,请描述实现思路,列出哪些类和对象,描述类的特点

4.实现一个带有验证码机制的登录功能,请列出所有相关的case,并描述每个case的实现思路,另外给出具体开发时的所有可能的代码文件列表及用处描述

5.上一题中,要求一个用户名不能被多个人同时登录,后登录者提示失败,请给出实现方案,要求支持集群系统,考虑尽可能全面

6.编写一个程序,传入一个参数(URL),根据该URL抓取页面并保存,该页面中的URL要继续抓取,依此类推。要求不能跨站抓取(只有和参数URL的域名一致的页面才抓取)。把所有页面抓取完毕后,程序自动退出。请给出你认为最完善的系统设计思路,假设页面的抓取函数,分析函数提供

7.请设计一个独立的封装良好的线程组类,其包含N个线程。其作用是能够并发处理

8.请描述集群系统和单服务器系统的差别?软件系统是否支持集群,设计上的关键差别点?设计一个数据记录量上千万或者过亿的高访问量的系统,你有哪些技术思路

9.要设计一个通用的软负载均衡系统(A系统),请给出设计思路和对应用系统(B,C,D,...)的对接规范的关键描述。应用系统要利用A系统实现负载均衡时,需要遵循A系统定义的规范。假设应用系统为C/S系统

10.给出一个完整的比较大的公司使用的的会议室预定系统的产品和设计思路,关键点描述,预定流程
...全文
257 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
qjl1000211038 2012-07-26
  • 打赏
  • 举报
回复
厉害!!
kafeihouye 2012-07-26
  • 打赏
  • 举报
回复
mysql数据库 第一题思路:1、内连接 2、根据班级分组 3、根据班级人数desc排序 4、分页显示
mysql 语句如下:
#班级表
CREATE TABLE tb_class
(
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
NAME VARCHAR(20)
)
#学生表
CREATE TABLE tb_student
(
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
NAME VARCHAR(20),
classId INT NOT NULL,
FOREIGN KEY(classId) REFERENCES tb_class(id)
)
#查询
SELECT COUNT(a.name) AS '班级人数',a.name FROM tb_class AS a
INNER JOIN tb_student AS b WHERE a.id=b.classId GROUP BY b.classId ORDER BY COUNT(b.name) DESC LIMIT 5
luzhiqin 2011-09-23
  • 打赏
  • 举报
回复
顶起。。各种好心人啊
Lazy_LaLa 2011-09-23
  • 打赏
  • 举报
回复
select * from (select class.name,count(student.Id) from class,student where class.Id= student.classId group by class.name order by count(student.Id) desc) where rownum <=5;(oracle) 好像还要加一个 desc 吧,要不然就没有做出题目的最终效果了。。!
袁莱 2011-08-27
  • 打赏
  • 举报
回复
资源被锁定,只能往里放!
[Quote=引用 5 楼 k3108001263 的回复:]
问题太多,只回答3,剩下的留给后人继续


Java code


import java.util.*;


public class TestPutAndGetApple {

List<Apple> apples = null;
public int appleSize = 0;//苹果总数 苹果数有限制
publi……
[/Quote]
袁莱 2011-08-27
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 k3108001263 的回复:]
把苹果总数限制为10,可能出现的结果

Java code

/*
放进1个,苹果ID是0苹果筐共有1个苹果
取出1个,苹果ID是0苹果筐共有0个苹果
放进1个,苹果ID是1苹果筐共有1个苹果
放进1个,苹果ID是2苹果筐共有2个苹果
取出1个,苹果ID是1苹果筐共有1个苹果
放进1个,苹果ID是3苹果筐共有2个苹果
取出1个,苹果ID是2苹果筐共有1个苹果
放进1个,苹果……
[/Quote]
结果不是这样吧,好像第2个线程不会运行
袁莱 2011-08-27
  • 打赏
  • 举报
回复
2、Java code
import java.util.Arrays;

public class Select7from30 {

int[] a = new int[31];
boolean[] b = new boolean[31];
int[] result;
private void initInt(int[] a) {
for(int i=1;i<a.length;i++){
a[i]=i;
}
}
private void initBoolean(boolean[] b){
for(int i=1;i<b.length;i++) {
b[i]= false;
}
}
private int[] get(int[] a,boolean[] b){
int[] result = new int[7];
for(int i=0;i<7;i++){
int random = (int)(Math.random()*30);
while((b[random]==true)||(random==0)) random = (int)(Math.random()*30);
b[random] = true;
result[i] = a[random];
}
return result;
}

public static void main(String[] args) {
Select7from30 sf = new Select7from30();
sf.initInt(sf.a);
System.out.println(Arrays.toString(sf.a));
sf.initBoolean(sf.b);
sf.result=sf.get(sf.a, sf.b);
System.out.println(Arrays.toString(sf.result));
Arrays.sort(sf.result);
System.out.println(Arrays.toString(sf.result));
}

}
kiss601459202 2011-08-27
  • 打赏
  • 举报
回复
20分 10个题目 一个题目2分!!!!!!!!!!!!!!!!绝对超值
淡定的峰哥 2011-08-27
  • 打赏
  • 举报
回复
看起来不像是暑假作业,后面几个还是有点高度的
第三题是个生产者、消费者的程序,要加锁的
第四题 随机验证码用servlet生成,并放到session中,然后页面调用,提交之后与session中的比对

public class DynamicPasswordServlet extends HttpServlet {

private static final long serialVersionUID = 2766016519012092763L;

private String keyFontName = "Rage Italic";

private int keyWidth = 25;

private int keyHeight = 25;

private int keyFontSize = 48;

/**
*
*/
public DynamicPasswordServlet() {
super();
}

protected void service(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {

HttpSession session = request.getSession();
int[] imageOrder = null;

try {

String orderString = (String)session.getAttribute( "ctpPassword" );
String timestamps = (String)session.getAttribute("time");
String timestamp = (String)request.getParameter("time");
if (orderString == null || orderString.length() == 0 ||(!timestamp.equals(timestamps))) // 没有生成,重新生成
{
DynamicPasswordBean bean = new DynamicPasswordBean();
imageOrder = bean.generateRadomSerial(10);
// imageOrder = new int[]{ 4,7,2,3,6,5,1,9,0,8};
orderString = packOrder(imageOrder);
session.setAttribute( "ctpPassword", orderString );
session.setAttribute( "time", timestamp );
//EMPLog.log( EMPConstance.ATTR_SESSION_CONTEXT, EMPLog.INFO, 0, "解包前1:"+orderString);
}else{
//EMPLog.log( EMPConstance.ATTR_SESSION_CONTEXT, EMPLog.INFO, 0, "解包前2:"+orderString);
imageOrder = parserOrder(orderString, 10);
}

} catch (Exception e) {
System.out.println(e.toString());
}

int idx = Integer.parseInt(request.getParameter("img"));

//EMPLog.log( EMPConstance.ATTR_SESSION_CONTEXT, EMPLog.INFO, 0, "前台键盘Id:"+idx);

// 在内存中创建图象
int width = keyWidth, height = keyHeight;

BufferedImage image = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB);

// 获取图形上下文
Graphics g = image.getGraphics();

// 设定背景色
// Color color = new Color(0x1A4876);
//g.setColor(new Color(224,224,224));
g.setColor(new Color(255,255,255));
// g.setColor(Color.GREEN);
g.fillRect(0, 0, width, height);
/*g.setColor(new Color(179,179,179));
g.fillRoundRect(0, 0, width, height,width/2,height/2);*/

//画阴影
/*g.setColor(Color.black);
g.drawLine(0, 0, 0, height);
g.drawLine(1, 0, 1, height);
g.drawLine(0, height, width, height);
g.drawLine(0, height-1, width, height-1);*/

// 设定字体
g.setFont(new Font(keyFontName, Font.PLAIN, keyFontSize)); // Arial

//g.setColor(Color.black);
FontMetrics metrics = g.getFontMetrics();

// System.out.println("FontHeight: " + metrics.getHeight());
// System.out.println("FontLeading: " + metrics.getLeading());
// System.out.println("FontAscent: " + metrics.getAscent());
// System.out.println("FontDescent: " + metrics.getDescent());

// try to draw some ramdon line's
/*
Random random = new Random(System.currentTimeMillis() + seed++);
for (int i = 0; i < width / 3; i++) {
Color aColor = new Color(random.nextInt(0xffffff));
g.setColor(aColor);

int x0 = random.nextInt(width);
int y0 = random.nextInt(height);
int xe = random.nextInt(width);
int ye = random.nextInt(height);

//g.drawLine(x0, y0, xe, ye);
}*/

int x0 = (width - metrics.getWidths()['9']) / 2;

int y0 = metrics.getAscent()+ metrics.getLeading() / 2+2; // /2 +
// metrics.getAscent();

/*int colorIdx = random.nextInt(4);
if (colorIdx == 0)
g.setColor(new Color(24, 73, 181)); // Color.RED );
if (colorIdx == 1)
g.setColor(new Color(214, 36, 8)); // Color.YELLOW );
if (colorIdx == 2)
g.setColor(new Color(16, 150, 24)); // Color.GREEN );
if (colorIdx == 3)
g.setColor(new Color(239, 186, 0)); // Color.BLUE );
*/
// g.setXORMode(Color.GREEN);
//g.setColor(Color.black);
g.setColor(new Color(70,70,70));
g.drawString(String.valueOf(imageOrder[idx]), x0, y0);

//EMPLog.log( EMPConstance.ATTR_SESSION_CONTEXT, EMPLog.INFO, 0, "键盘"+idx+"加密生成:"+imageOrder[idx]);

// 输出密码序号图片
OutputStream outputStream = null;
try {
outputStream = response.getOutputStream();
response.setContentType("image/jpeg");
//设置页面不缓存
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);

JPEGImageEncoder encoder = JPEGCodec
.createJPEGEncoder(outputStream);
JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(image);
param.setQuality(1.0F,true);
encoder.setJPEGEncodeParam(param);
encoder.encode(image);
outputStream.flush();
} catch (IOException ex) {
throw ex;
} finally {
if (outputStream != null) {
try {
outputStream.close();
} catch (IOException ex) {
}
}
}
}

private String packOrder(int order[]){
String ordS = "";
for(int i=0; i<order.length; i++){
ordS += String.valueOf(order[i]) + "|";
}
return ordS;
}

private int[] parserOrder(String orderS , int maxValue){
int serialValue[] = new int[maxValue];
String tmp = orderS;
int i = 0;
int indx = -1;
while((indx = tmp.indexOf('|')) > 0){
serialValue[i] = Integer.parseInt(tmp.substring(0,indx));
tmp = tmp.substring(indx+1);
i++;
}
return serialValue;
}



public void init(ServletConfig sc) {
try {
super.init(sc);

// private String certifyFontName = "Rage Italic";
// private String keyFontName = "Rage Italic";
//
// private int keyWidth = 48;
// private int keyHeight = 48;

String tmpValue;

tmpValue = getInitParameter("keyFontName");
if (tmpValue != null)
keyFontName = tmpValue;

tmpValue = getInitParameter("keyFontSize");
if (tmpValue != null)
keyFontSize = Integer.parseInt(tmpValue);

tmpValue = getInitParameter("keyWidth");
if (tmpValue != null)
keyWidth = Integer.parseInt(tmpValue);

tmpValue = getInitParameter("keyHeight");
if (tmpValue != null)
keyHeight = Integer.parseInt(tmpValue);

} catch (Exception e) {
e.printStackTrace();
}
}

}


页面使用

<input type="text" name="tempCheckCode" id="tempCheckCode" size="12" maxlength="4" style="height:16px;" /> <img id="verifyImg" src="VerifyImage" align="absmiddle" onclick="this.src='VerifyImage?update=' + Math.random()" style="cursor:pointer;" title="点击图片可刷新验证码"/>
看不清?<a href="#1" onclick="javascript:document.getElementById('verifyImg').src='VerifyImage?update=' + Math.random()" class="blue12">换一张</a>

第五题,单点登录,方法是登录时检查用户的标志,成功了将用户的标志存入数据库,用户点退出和关掉网页都将这条记录删除
第六题,是一个搜索引擎的功能,一般采取非递归结构,构造一个队列,当扫描网页的时候出现超链接,就把这个超链接加入到等待队列中,然后接着扫描,至道网页扫描完,再开始下一个队列,一般多线程实现效率高,现在有一个开源的搜索引擎Lucene,你可以去网上找找资料
打油的程序员 2011-08-27
  • 打赏
  • 举报
回复
把苹果总数限制为10,可能出现的结果

/*
放进1个,苹果ID是0苹果筐共有1个苹果
取出1个,苹果ID是0苹果筐共有0个苹果
放进1个,苹果ID是1苹果筐共有1个苹果
放进1个,苹果ID是2苹果筐共有2个苹果
取出1个,苹果ID是1苹果筐共有1个苹果
放进1个,苹果ID是3苹果筐共有2个苹果
取出1个,苹果ID是2苹果筐共有1个苹果
放进1个,苹果ID是4苹果筐共有2个苹果
取出1个,苹果ID是3苹果筐共有1个苹果
取出1个,苹果ID是4苹果筐共有0个苹果
放进1个,苹果ID是5苹果筐共有1个苹果
取出1个,苹果ID是5苹果筐共有0个苹果
放进1个,苹果ID是6苹果筐共有1个苹果
放进1个,苹果ID是7苹果筐共有2个苹果
放进1个,苹果ID是8苹果筐共有3个苹果
取出1个,苹果ID是6苹果筐共有2个苹果
取出1个,苹果ID是7苹果筐共有1个苹果
放进1个,苹果ID是9苹果筐共有2个苹果
取出1个,苹果ID是8苹果筐共有1个苹果
取出1个,苹果ID是9苹果筐共有0个苹果

*/
打油的程序员 2011-08-27
  • 打赏
  • 举报
回复
问题太多,只回答3,剩下的留给后人继续



import java.util.*;


public class TestPutAndGetApple {

List<Apple> apples = null;
public int appleSize = 0;//苹果总数 苹果数有限制
public TestPutAndGetApple(int appleSize) {
this.appleSize = appleSize;
apples = new ArrayList<Apple>(appleSize);;
}
public static void main(String[] args) {
TestPutAndGetApple tpaga = new TestPutAndGetApple(100);
new Thread(new TestPutAppleRunnable(tpaga)).start();
new Thread(new TestGetAppleRunnable(tpaga)).start();

}
}

class Apple {
static int count = 0;
final int id = count++;
public int getId() {
return id;
}
}


class TestPutAppleRunnable implements Runnable {
int putAppleCount = 0;
TestPutAndGetApple tpaga;
public TestPutAppleRunnable(TestPutAndGetApple tpaga) {
this.tpaga = tpaga;
}

public void run() {
while (putAppleCount<tpaga.appleSize) {
Apple apple = new Apple();
putAppleCount++;
tpaga.apples.add(apple);
System.out.println("放进1个,苹果ID是"+ apple.getId()+"苹果筐共有" + tpaga.apples.size()
+ "个苹果");
try {
Thread.sleep((int) (Math.random() * 2000));//速度太快了,延迟一下
} catch (InterruptedException e) {
}
}
}

}

class TestGetAppleRunnable implements Runnable {
TestPutAndGetApple tpaga;
public TestGetAppleRunnable(TestPutAndGetApple tpaga) {
this.tpaga = tpaga;
}

public void run() {
while (true) {
if (!tpaga.apples.isEmpty()) {
Apple apple = tpaga.apples.remove(0);
System.out.println("取出1个,苹果ID是"+ apple.getId()+"苹果筐共有" + tpaga.apples.size()
+ "个苹果");
}
try {
Thread.sleep((int) (Math.random() * 2000));//速度太快了,延迟一下
} catch (InterruptedException e) {
}
}
}

}


jason_deng 2011-08-27
  • 打赏
  • 举报
回复
select * from (select class.name,count(student.Id) from class,student where class.Id= student.classId group by class.name order by count(student.Id)) where rownum <=5;(oracle)
qybao 2011-08-26
  • 打赏
  • 举报
回复
问题太多,只回答1,2,剩下的留给后人继续
1 没测试过,不过应该是每种数据库都能对应
select a.name 
from class a,
(select b.classid as classid,
(select count(1)
from (select classid, count(1) as cnt
from student
group by classid) c
where c.cnt > (select count(1)
from student
where classid = b.classid)
) as rank
from stuent b) d
where a.id = d.classid
and d.rank < 5
order by d.rank


2
List<Integer> list = new LinkedList<Integer>();
for (int i=0; i<30; i++) { //准备30个数
list.add(i+1);
}
List<Integer> result = new ArrayList<Integer>();
for (int i=0; i<7; i++) { //随机取7个放到结果集
result.add(list.remove((int)(Math.random()*list.size())));
}
Collections.sort(result); //排序
for (Integer i : result) { //打印
System.out.println(i);
}
袁莱 2011-08-26
  • 打赏
  • 举报
回复
select * from (select class.name,count(student.Id) from class,student where class.Id= student.classId group by class.name order by count(student.Id)) where rownum <=5;(oracle)
一洽客服系统 2011-08-26
  • 打赏
  • 举报
回复
一看内容就准备跑了 帮你顶起等热心人哈哈
liuyuhua0066 2011-08-26
  • 打赏
  • 举报
回复
暑假作业?

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧