2015恒生电子校招笔试题

一、不定项选择题

1、B  C错是因为编译后还需要链接,D函数可以单独编译,编译成目标文件

2、

3、D

4、CD

5、

6、B

7、

(1)C

(2)A

8、D

9、

10、ABCD

 

二、JAVA语言部分

1、B

2、C

3、AB  char型用'\u四位的16进制'表示也是正确的

4、AB

5、AB,B

 

 

三、数据库

create table S(
    Sno int primary key auto_increment,
    Sname varchar(20)

);

insert into S(sname) values('he');
insert into S(sname) values('wang');

create table C(
    Cno int primary key auto_increment,
    Cname varchar(20),
    Ccredit int
);


insert into C(cname,Ccredit) values('JAVA',3);
insert into C(cname,Ccredit)  values('C',2);

Drop table if exists SC;
create table SC(
    id int primary key auto_increment,
    Sno int,
    Cno int,
    Grade int
);


insert into SC(Sno,cno,Grade) values(1,1,100);
insert into SC(Sno,cno,Grade) values(1,2,90);
insert into SC(Sno,cno,Grade) values(2,1,80);
insert into SC(Sno,cno,Grade) values(2,2,70);
insert into SC(Sno,cno,Grade,Teacher) values(3,1,80,'zhang');
insert into SC(Sno,cno,Grade,Teacher) values(3,2,70,'zhang');

1)select distinct Sname From S,SC,C where S.sno = SC.sno and c.Cno = SC.cno and
Cname='JAVA' order by Sname desc;

2)select S.Sno,Sum(Ccredit) From S,SC,C where S.sno = SC.sno and c.Cno = SC.cno

and Grade>60 group by Sno having sum(Ccredit)>80;

3)ALTER table SC ADD Teacher varchar(20) not null;

4)CREATE VIEW SCSum(sno,Ccredit) as Select S.Sno,Sum(Ccredit)  From S,SC,C

where S.sno = SC.sno and c.Cno = SC.cno group by Sno;  

5)delete from SC where sno not in(select distinct S.Sno from S);

 

四、编程题

1、

package hengsheng;

import java.util.Scanner;

public class Exe3 {
    public static void main(String[] args) {
        Date date = new Date(2015,8,25);
        System.out.println(days(date));
    
    }

    static int days(Date date){
        int day = 0;
        int[][] month = new int[][]{{31,28,30,31,30,31,31,31,30,31,30,31},{31,29,30,31,30,31,31,31,30,31,30,31}};
        int m = isrunYear(date.getYear());
        for(int i=0;i<date.getMonth()-1;i++){
            day += month[m][i];
        }
        day += date.getDay();
        return day;
    }
    
    static int isrunYear(int year) {
        if (year % 4 == 0 && year % 100 != 0 | year % 400 == 0)
            return 0;
        return 1;
    }
}

class Date {
    int year;
    int month;
    int day;

    
    public Date(int year, int month, int day) {
        super();
        this.year = year;
        this.month = month;
        this.day = day;
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }

    public int getMonth() {
        return month;
    }

    public void setMonth(int month) {
        this.month = month;
    }

    public int getDay() {
        return day;
    }

    public void setDay(int day) {
        this.day = day;
    }

}

 

2、

package hengsheng;

import java.util.Scanner;

public class Exe2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        while (n != 1) {
            for (int i = 2; i<=n; i++) {
                if (isPrime(i)) {                    
                    // 如果i为素数
                    if (n % i == 0) {
                        // 如果n能被i整数
                        n = n / i;
                        System.out.print(i + " ");
                        break;
                    }
                }
            }
        }
    }

    /**
     * 判断是否是素数
     * 
     * @param num
     * @return
     */
    static boolean isPrime(int num) {
        for (int i = 2; i <= num / 2; i++)
            if (num % i == 0)
                return false;
        return true;
    }

}

 

转载于:https://www.cnblogs.com/hzhtracy/p/4761174.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值