2008-05-08
题库贴
关键字: 面试题
大家如果有好的题目可以贴出来,以后大家练练手,我会定时整理的。
1。[java]java实现,计算 100 的阶乘的值。打印出结果
2。有两个人 从一个框里面拿球,总共有500 个球,A每次可以拿1-5个球,B可以拿1-5个球。现在A、B两人轮流拿球。A第一次拿多少个球 才能保证最后一次是A拿球。说明理由。
3。[SQL]
有一个表 :table(SID,PCLASS,PSCORE),有三个字段分别是学生ID,班级,分数。如果当前表内数据状态为:
1 1 60
2 1 60
3 1 90
4 2 100
5 3 80
6 3 95
7 4 50
写一个SQL语句,求 班级人数>1的每个班级最大分数。 只需要求得两个字段:班级,分数
结果:
1 90
3 95
END
4。[SQL]有个数据表记录每日消费额度,刚开始某人有 100块前。从第一天开始 如果他消费了一些钱,那么数据库会增加一条记录,记录下 余额。 当100天以后。 写一条SQL语句打印出他每天的消费额。
1。[java]java实现,计算 100 的阶乘的值。打印出结果
2。有两个人 从一个框里面拿球,总共有500 个球,A每次可以拿1-5个球,B可以拿1-5个球。现在A、B两人轮流拿球。A第一次拿多少个球 才能保证最后一次是A拿球。说明理由。
3。[SQL]
有一个表 :table(SID,PCLASS,PSCORE),有三个字段分别是学生ID,班级,分数。如果当前表内数据状态为:
1 1 60
2 1 60
3 1 90
4 2 100
5 3 80
6 3 95
7 4 50
写一个SQL语句,求 班级人数>1的每个班级最大分数。 只需要求得两个字段:班级,分数
结果:
1 90
3 95
END
4。[SQL]有个数据表记录每日消费额度,刚开始某人有 100块前。从第一天开始 如果他消费了一些钱,那么数据库会增加一条记录,记录下 余额。 当100天以后。 写一条SQL语句打印出他每天的消费额。
评论
jonson
2008-05-17
1。100的阶乘的程序:
init:
deps-jar:
Compiling 1 source file to C:\Documents and Settings\Administrator\My Documents\NetBeansProjects\HelloWorldApp\build\classes
compile-single:
run-single:
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000093326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000
time usage:63
BUILD SUCCESSFUL (total time: 4 seconds)
该实现是利用数组来保存临时值。
时间:63 微秒
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*<p>计算 100! 的值</p>
* @author Administrator
*/
public class MultiValue {
private static int[] getArrayFromInt(int value) {
String temp = String.valueOf(value);
byte[] a = temp.getBytes();
int[] result = new int[a.length];
for(int i = 0;i < a.length;i++)
{
result[i] = Integer.parseInt(Character.toString((char)a[i]));
}
return result;
}
public static void main(String[] args)
{
long start = System.currentTimeMillis();
int[] result = caculator(100);
for(int i = 0;i<result.length;i++)
{
System.out.print(result[i]);
}
long end = System.currentTimeMillis();
System.out.println();
System.out.println("time usage:"+(end-start));
}
private class IllegalParamException extends Exception
{
public IllegalParamException(){}
public IllegalParamException(String message){
super(message);
}
}
static public int[] caculator(int v) {
//System.out.println(Arrays.toString(a));
if(v < 0)
{
return new int[]{1};
//return {'1'};
}else if(v ==0)
{
return new int[]{1};
}else
{
return process(caculator(v-1),v);
}
}
//数组的结构为:[1,2,3,4] x 99,value <=100
//write test
static private int[] process(int[] caculator, int value) {
//(n-1)! x n = n! 1234 x 99 =
int[] aValue = getArrayFromInt(value);
//临时数据存储单元
int ten_temp = 0;
int[][] temp1=new int[aValue.length][caculator.length+3];
for(int i=0;i<aValue.length;i++)
{
for(int j=0;j<caculator.length;j++)
{
int tt = aValue[aValue.length-1-i]*caculator[caculator.length-1-j];
temp1[i][caculator.length+2-i-j]=(tt+ ten_temp)%10 ;
ten_temp = (tt+ten_temp) / 10;
}
temp1[i][2 - i] = ten_temp;
ten_temp = 0;
}
ten_temp = 0;
int[] result = new int[caculator.length+3];
for(int i=0;i<caculator.length+3;i++)
{
int tttt =0;
for(int j=0;j<temp1.length;j++)
{
tttt = tttt +temp1[j][caculator.length+2-i];
}
result[caculator.length+2-i] = (tttt + ten_temp)%10;
ten_temp = (tttt + ten_temp) / 10;
}
return result;
}
}
init:
deps-jar:
Compiling 1 source file to C:\Documents and Settings\Administrator\My Documents\NetBeansProjects\HelloWorldApp\build\classes
compile-single:
run-single:
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000093326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000
time usage:63
BUILD SUCCESSFUL (total time: 4 seconds)
该实现是利用数组来保存临时值。
时间:63 微秒
firefox_1983
2008-05-08
3.SELECT PCLASS, PSCORE from (select PCLASS,max(PSCORE) as PSCORE ,count(PSCORE) count from class_score
group by PCLASS) Temp where count>1
group by PCLASS) Temp where count>1
jonson
2008-05-08
难道大家都是超级高手!!都不需要练手?还是觉得题目太简单!
其实在工作之余 做做小题目练练手,我觉得还不错阿。
其实在工作之余 做做小题目练练手,我觉得还不错阿。
发表评论
提醒: 该博客已发表在公共论坛,博客所有留言会成为论坛回贴,留言请注意遵守论坛发贴规则
- 浏览: 2857 次
- 性别:

- 来自: 杭州

- 详细资料
搜索本博客
我的相册
大竹海04
共 2 张
共 2 张
最近加入圈子
最新评论
-
js 函数的定义、运行 顺 ...
niuyuewanzi 写道jonson 写道afcn0 写道大哥你不会指的是这 ...
-- by cyan19851224 -
题库贴
1。100的阶乘的程序: /* * To change this t ...
-- by jonson -
题库贴
3.SELECT PCLASS, PSCORE from (select PCL ...
-- by firefox_1983 -
题库贴
难道大家都是超级高手!!都不需要练手?还是觉得题目太简单!其实在工作之余 做做小 ...
-- by jonson -
丑陋的继承
jonson 写道bluemeteor 写道AbstractTopicPO |_ ...
-- by 抛出异常的爱






评论排行榜