day18—选择题

1.如下SQL语句中,(D)可能返回null值

(1) select count(*) from t1;
(2) select max(col1) from t1;
(3) select concat(‘max=’,max(col1)) from t1;
A (1)可能,(2)和(3)不可能
B (2)可能,(1)和(3)不可能
C (3)可能,(1)和(2)不可能
D (1)不可能,(2)和(3)可能
E 都不可能
F 都可能

思路:count(*)一定可以返回数值,如果是表中没有数据就返回0;max返回null可能的情况有两种:其一是表中没有数据,还有就是字段的值全部都是null;concat是字符串拼接的函数,因为数据库中字符串拼接不能使用+,如果拼接的其中一个字符串是null,结果就是null

2. 在Sql server中,以下哪一句从表TABLE_NAME中提取前10条记录(B)

A select * from TABLE_NAME where rowcount=10
B select TOP 10 * from TABLE_NAME
C select TOP of 10 * from TABLE_NAME
D select * from TABLE_NAME where rowcount<=10

思路:top是SQL server中的关键字,用于求前n条数据;语法:select top n 查询的字段 from…

3.电话号码表t_phonebook中含有100万条数据,其中号码字段PhoneNo上创建了唯一索引,且电话号码全部由数字组成,要统计号码头为321的电话号码的数量,下面写法执行速度最慢的是(C)

A select count() from t_phonebook where phoneno >= ‘321’ and phoneno < ‘321A’
B select count(
) from t_phonebook where phoneno like ‘321%’
C select count(*) from t_phonebook where substr(phoneno,1,3) = ‘321’
D 都一样快

思路:phoneno是数字组成,使用的是数值数据类型,和字符串可以比较,但是会进行类型转化,可以使用索引;模糊匹配,最开始是321的匹配,可以使用索引;使用函数就不会再使用索引,就会全表扫描,函数本身的执行也是需要耗时的

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Section1 1. The orange is too high on the tree . It’s out of my reach(伸出手).I need someone to help me. 2. The city is named after famous president. (这个城市是著名的总统名字命名的) named after短语”命名” 3. It took millions of people several years to build the Great Wall. 4. I have always considered(考虑过的/认为) you my best friend. 5. If I take this medicine twice a day, it should cure (治愈)my cold.. 如果我服用此药,一天两次,就应该治愈我的感冒 6. It is considerate 考虑周到的 of you to turn down the radio while your sister is still ill in bed. 这是体贴你调低收音机,你的妹妹还在床上生病。 7. It’s not quite certain 肯定that he will be present at the meeting. 这不是肯定的是,他将出席会议 8. It was natural (自然)that he count(计算) the days before going home. 9. when she saw the clouds(乌去密布) she went back to house to fetch(取) her umbrella(伞). 10. The metals which we find in the earth include(包括) iron , lead and copper. 在我们地球上发现金属包括有铁,铅和铜 11. Your hair needs to be cut(剪) ;would you like me to do it for you.. 12. It was difficult难 to guess猜测 what her reaction反应 to the news消息 would be. 13. Contrary相反 to your prediction预言 , they lost the game.. 14. We say that a person has good manners if he or she is polite , kind and helpful to others. 我们说一个人具有良好的风度,如果他或她是有礼貌,善良和乐于助人。
一些经典的习题 【程序1】 题目:古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一对兔子,假如兔子都不死,问每个月的兔子总数为多少? 1.程序分析: 兔子的规律为数列1,1,2,3,5,8,13,21.... 【程序2】 题目:判断101-200之间有多少个素数,并输出所有素数。 1.程序分析:判断素数的方法:用一个数分别去除2到sqrt(这个数),如果能被整除, 则表明此数不是素数,反之是素数。 【程序3】 题目:打印出所有的"水仙花数",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该数本身。例如:153是一个"水仙花数",因为153=1的三次方+5的三次方+3的三次方。 1.程序分析:利用for循环控制100-999个数,每个数分解出个位,十位,百位。 【程序4】 题目:将一个正整数分解质因数。例如:输入90,打印出90=2*3*3*5。 程序分析:对n进行分解质因数,应先找到一个最小的质数k,然后按下述步骤完成: (1)如果这个质数恰等于n,则说明分解质因数的过程已经结束,打印出即可。 (2)如果nk,但n能被k整除,则应打印出k的值,并用n除以k的商,作为新的正整数你n,重复执行第一步。 (3)如果n不能被k整除,则用k+1作为k的值,重复执行第一步。 【程序5】 题目:利用条件运算符的嵌套来完成此题:学习成绩>=90分的同学用A表示,60-89分之间的用B表示,60分以下的用C表示。 1.程序分析:(a>b)?a:b这是条件运算符的基本例子。 【程序6】 题目:输入两个正整数m和n,求其最大公约数和最小公倍数。 1.程序分析:利用辗除法。 【程序7】 题目:输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。 1.程序分析:利用while语句,条件为输入的字符不为'\n'. 【程序8】 题目:求s=a+aa+aaa+aaaa+aa...a的值,其中a是一个数字。例如2+22+222+2222+22222(此时共有5个数相加),几个数相加有键盘控制。 1.程序分析:关键是计算出每一项的值。 【程序9】 题目:一个数如果恰好等于它的因子之和,这个数就称为"完数"。例如6=1+2+3.编程 找出1000以内的所有完数。 【程序10】 题目:一球从100米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在 第10次落地时,共经过多少米?第10次反弹多高? 【程序11】 题目:有1、2、3、4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少? 1.程序分析:可填在百位、十位、个位的数字都是1、2、3、4。组成所有的排列后再去 掉不满足条件的排列。 【程序12】 题目:企业发放的奖金根据利润提成。利润(I)低于或等于10万元时,奖金可提10%; 利润高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可提成7.5%; 20万到40万之间时,高于20万元的部分,可提成5%; 40万到60万之间时高于40万元的部分,可提成3%; 60万到100万之间时,高于60万元的部分,可提成1.5%, 高于100万元时,超过100万元的部分按1%提成,从键盘输入当月利润I,求应发放奖金总数? 1.程序分析:请利用数轴来分界,定位。注意定义时需把奖金定义成长整型。 【程序13】 题目:一个整数,它加上100后是一个完全平方数,再加上168又是一个完全平方数,请问该数是多少? 1.程序分析:在10万以内判断,先将该数加上100后再开方,再将该数加上268后再开方,如果开方后的结果满足如下条件,即是结果。请看具体分析: public class FullSquare { public static void main(String[] args) { int t = 0; for (int i = 1; i <= 100; i++) { t = i + 100; for (int j = 1; j <= 100; j++) { if (t == j * j) { t = t + 168; for (int p = 1; p <= 100; p++) { if (t == p * p) System.out.println(i); } } } } } } 【程序14】 题目:输入某年某月某日,判断这一天是这一年的第几天? 1.程序分析:以3月5日为例,应该先把前两个月的加起来,然后再加上5天即本年的第几天,特殊情况,闰年且输入月份大于3时需考虑多加一天。 import java.util.Scanner; //题目:输入某年某月某日,判断这一天是这一年的第几天 public class ThisDayIs { public static void main(String[] args) { System.out.println("请输入年份,如:2008"); Scanner YMD = new Scanner(System.in); int year = YMD.nextInt(); System.out.println("请输入月份1~12,如8"); int month = YMD.nextInt(); System.out.println("请输入天数1~31,如8"); int day = YMD.nextInt(); if (LeapYear(year)) { switch (month) { case 1: { System.out.println("这是" + year + "的第" + day + "天"); break; } case 2: { day = day + 31; System.out.println("这是" + year + "的第" + day + "天"); break; } case 3: { day = day + 29 + 31; System.out.println("这是" + year + "的第" + day + "天"); break; } case 4: { day = day + 29 + 31 * 2; System.out.println("这是" + year + "的第" + day + "天"); break; } case 5: { day = day + 29 + 31 * 2 + 30; System.out.println("这是" + year + "的第" + day + "天"); break; } case 6: { day = day + 29 + 31 * 3 + 30; System.out.println("这是" + year + "的第" + day + "天"); break; } case 7: { day = day + 29 + 31 * 3 + 30 * 2; System.out.println("这是" + year + "的第" + day + "天"); break; } case 8: { day = day + 29 + 31 * 4 + 30 * 2; System.out.println("这是" + year + "的第" + day + "天"); break; } case 9: { day = day + 29 + 31 * 5 + 30 * 2; System.out.println("这是" + year + "的第" + day + "天"); break; } case 10: { day = day + 29 + 31 * 5 + 30 * 3; System.out.println("这是" + year + "的第" + day + "天"); break; } case 11: { day = day + 29 + 31 * 6 + 30 * 3; System.out.println("这是" + year + "的第" + day + "天"); break; } case 12: { day = day + 29 + 31 * 6 + 30 * 4; System.out.println("这是" + year + "的第" + day + "天"); break; } } } else switch (month) { case 1: { System.out.println("这是" + year + "的第" + day + "天"); break; } case 2: { day = day + 31; System.out.println("这是" + year + "的第" + day + "天"); break; } case 3: { day = day + 28 + 31; System.out.println("这是" + year + "的第" + day + "天"); break; } case 4: { day = day + 28 + 31 * 2; System.out.println("这是" + year + "的第" + day + "天"); break; } case 5: { day = day + 28 + 31 * 2 + 30; System.out.println("这是" + year + "的第" + day + "天"); break; } case 6: { day = day + 28 + 31 * 3 + 30; System.out.println("这是" + year + "的第" + day + "天"); break; } case 7: { day = day + 28 + 31 * 3 + 30 * 2; System.out.println("这是" + year + "的第" + day + "天"); break; } case 8: { day = day + 28 + 31 * 4 + 30 * 2; System.out.println("这是" + year + "的第" + day + "天"); break; } case 9: { day = day + 28 + 31 * 5 + 30 * 2; System.out.println("这是" + year + "的第" + day + "天"); break; } case 10: { day = day + 28 + 31 * 5 + 30 * 3; System.out.println("这是" + year + "的第" + day + "天"); break; } case 11: { day = day + 28 + 31 * 6 + 30 * 3; System.out.println("这是" + year + "的第" + day + "天"); break; } case 12: { day = day + 28 + 31 * 6 + 30 * 4; System.out.println("这是" + year + "的第" + day + "天"); break; } } } private static boolean LeapYear(int year) { if (year % 4 == 0 || year % 100 == 0){ System.out.print(year+"是闰年"); return true; } else return false; } } import java.util.Scanner; //题目:输入某年某月某日,判断这一天是这一年的第几天 public class ThisDayIs { public static void main(String[] args) { System.out.println("请输入年份,如:2008"); Scanner YMD = new Scanner(System.in); int year = YMD.nextInt(); System.out.println("请输入月份1~12,如8"); int month = YMD.nextInt(); System.out.println("请输入天数1~31,如8"); int day = YMD.nextInt(); int[] temp = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; if (LeapYear(year)) { temp[2] = temp[2] + 1; for (int i = 0; i < month; i++) { day += temp[i]; } System.out.println("这是" + year + "的第" + day + "天"); } else { for (int i = 0; i y则将x与y的值进行交换,然后再用x与z进行比较,如果x>z则将x与z的值进行交换,这样能使x最小。 import java.util.Scanner; //题目:输入三个整数x,y,z,请把这三个数由小到大输出。 public class CompareThreeNumber { public static void main(String[] args) { System.out.println("请输入三个数"); Scanner Three = new Scanner(System.in); int xThree = Three.nextInt(); int yThree = Three.nextInt(); int zThree = Three.nextInt(); int temp; if (xThree >= yThree) { temp = xThree; xThree = yThree; yThree = temp; if (yThree >= zThree) { temp = yThree; yThree = zThree; zThree = temp; if (xThree >= yThree) temp = xThree; xThree = yThree; yThree = temp; } } else if (yThree >= zThree) { temp = yThree; yThree = zThree; zThree = temp; if (xThree >= yThree) { temp = xThree; xThree = yThree; yThree = temp; } } System.out.println(xThree + "<" + yThree + "<" + zThree); } } 【程序16】 题目:输出9*9口诀。 1.程序分析:分行与列考虑,共9行9列,i控制行,j控制列。 //题目:输出9*9口诀。 public class Formula99 { public static void main(String[] args) { for (int row = 1; row <= 9; row++) { for (int line = 1; line = 1;day--){ sum = (sum + 1) *2; System.out.println("第"+(day)+"天一共有"+sum+"个桃子"); } } } 【程序18】 题目:两个乒乓球队进行比赛,各出三人。甲队为a,b,c三人,乙队为x,y,z三人。已抽签决定比赛名单。有人向队员打听比赛的名单。 a说他不和x比,c说他不和x,z比,请编程序找出三队赛手的名单。 1.程序分析:判断素数的方法:用一个数分别去除2到sqrt(这个数),如果能被整除, 则表明此数不是素数,反之是素数。 【程序19】 题目:打印出如下图案(菱形) * *** ****** ******** ****** *** * 1.程序分析:先把图形分成两部分来看待,前四行一个规律,后三行一个规律,利用双重 for循环,第一层控制行,第二层控制列。 【程序20】 题目:有一分数序列:2/1,3/2,5/3,8/5,13/8,21/13...求出这个数列的前20项之和。 1.程序分析:请抓住分子与分母的变化规律。 //题目:有一分数序列:2/1,3/2,5/3,8/5,13/8,21/13...求出这个数列的前20项之和。 public class FractionSum { public FractionSum() { double sum = 0; for (double i = 2; i <= 20; i++) sum += F(i) / F(i - 1); System.out.println("这20项的结果是:" + sum); } public double F(double j) { if (j == 1) return 1; else if (j == 2) return 2; else return F(j - 1) + F(j - 2); } public static void main(String[] args) { new FractionSum(); } } 【程序21】 题目:求1+2!+3!+...+20!的和 1.程序分析:此程序只是把累加变成了累乘。 //题目:求1+2!+3!+...+20!的和 public class Factorial { public Factorial() { int sum = 0; for (int i = 1; i <= 20; i++) { int temp = 1; for (int j = 1; j <= i; j++) { temp *= j; } sum += temp; } System.out.println("前20个数的阶乘和为" + sum); } public static void main(String[] args) { new Factorial(); } } //题目:求1+2!+3!+...+20!的和 public class Factorial { public Factorial() { int sum = 0; for (int i = 1; i <= 4; i++) { sum += F(i); } System.out.println("前20个数的阶乘和为" + sum); } public int F(int n) { if (n == 1) return 1; else return n * F(n - 1); } public static void main(String[] args) { new Factorial(); } } 【程序22】 题目:利用递归方法求5!。 1.程序分析:递归公式:fn=fn_1*4! public class Recursion { public Recursion(int number) { System.out.println(number+"的阶乘是:"+F(number)); } public int F(int n) { if (n == 1) return 1; else return n * F(n - 1); } public static void main(String[] args){ new Recursion(5); } } 【程序23】 题目:有5个人坐在一起,问第五个人多少岁?他说比第4个人大2岁。问第4个人岁数,他说比第3个人大2岁。问第三个人,又说比第2人大两岁。问第2个人,说比第一个人大两岁。最后问第一个人,他说是10岁。请问第五个人多大? 1.程序分析:利用递归的方法,递归分为回推和递推两个阶段。要想知道第五个人岁数,需知道第四人的岁数,依次类推,推到第一人(10岁),再往回推。 【程序24】 题目:给一个不多于5位的正整数,要求:一、求它是几位数,二、逆序打印出各位数字。 【程序25】 题目:一个5位数,判断它是不是回文数。即12321是回文数,个位与万位相同,十位与千位相同。 【程序26】 题目:请输入星期几的第一个字母来判断一下是星期几,如果第一个字母一样,则继续 判断第二个字母。 1.程序分析:用情况语句比较好,如果第一个字母一样,则判断用情况语句或if语句判断第二个字母。 【程序27】 题目:求100之内的素数 【程序28】 题目:对10个数进行排序 1.程序分析:可以利用选择法,即从后9个比较过程中,选择一个最小的与第一个元素交换, 下次类推,即用第二个元素与后8个进行比较,并进行交换。 【程序29】 题目:求一个3*3矩阵对角线元素之和 1.程序分析:利用双重for循环控制输入二维数组,再将a[ i ][ i ]累加后输出。 【程序30】 题目:有一个已经排好序的数组。现输入一个数,要求按原来的规律将它插入数组中。 1. 程序分析:首先判断此数是否大于最后一个数,然后再考虑插入中间的数的情况,插入后此元素之后的数,依次后移一个位置。 【程序31】 题目:将一个数组逆序输出。 1.程序分析:用第一个与最后一个交换。 import java.util.Scanner; //题目:将一个数组逆序输出。 public class ArrayReverse { public ArrayReverse() { System.out.println("输入一个数指明数组长度"); Scanner number = new Scanner(System.in); int n = number.nextInt(); System.out.println("输入一个数组"); int[] Array = new int[n]; Reverse(Array); } public void Reverse(int[] Array) { Scanner array = new Scanner(System.in); for (int i = 0; i = 0; i++, j--) { int x, y; x = Array[i]; y = Array[j]; Array[j] = x; Array[i] = y; if (i >= j) break; } for (int i = 0; i < Array.length; i++) System.out.print(Array[i] + " "); } public static void main(String[] args) { new ArrayReverse(); } } 【程序32】 题目:取一个整数a从右端开始的4~7位。 程序分析:可以这样考虑: (1)先使a右移4位。 (2)设置一个低4位全为1,其余全为0的数。可用~(~0<<4) (3)将上面二者进行&运算。 【程序33】 题目:打印出杨辉三角形(要求打印出10行如下图) 1.程序分析: 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 【程序34】 题目:输入3个数a,b,c,按大小顺序输出。 1.程序分析:利用指针方法。 【程序35】 题目:输入数组,最大的与第一个元素交换,最小的与最后一个元素交换,输出数组。 【程序36】 题目:有n个整数,使其前面各数顺序向后移m个位置,最后m个数变成最前面的m个数 【程序37】 题目:有n个人围成一圈,顺序排号。从第一个人开始报数(从1到3报数),凡报到3的人退出圈子, 问最后留下的是原来第几号的那位。 【程序38】 题目:写一个函数,求一个字符串的长度,在main函数中输入字符串,并输出其长度。 【程序39】 题目:编写一个函数,输入n为偶数时,调用函数求1/2+1/4+...+1/n,当输入n为奇数时, 调用函数1/1+1/3+...+1/n(利用指针函数) 【程序40】 题目:字符串排序。 【程序41】 题目:海滩上有一堆桃子,五只猴子来分。第一只猴子把这堆桃子凭据分为五份,多了一个,这只猴子把多的一个扔入海中,拿走了一份。第二只猴子把剩下的桃子又平均分成五份,又多了一个,它同样把多的一个扔入海中,拿走了一份,第三、第四、第五只猴子都是这样做的,问海滩上原来最少有多少个桃子? 【程序42】 题目:809*??=800*??+9*??+1 其中??代表的两位数,8*??的结果为两位数,9*??的结果为3位数。求??代表的两位数,及809*??后的结果。 【程序43】 题目:求0—7所能组成的奇数个数。 【程序44】 题目:一个偶数总能表示为两个素数之和。 【程序45】 题目:判断一个素数能被几个9整除 【程序46】 题目:两个字符串连接程序 【程序47】 题目:读取7个数(1—50)的整数值,每读取一个值,程序打印出该值个数的*。 【程序48】 题目:某个公司采用公用电话传递数据,数据是四位的整数,在传递过程中是加密的,加密规则如下:每位数字都加上5,然后用和除以10的余数代替该数字,再将第一位和第四位交换,第二位和第三位交换。 【程序49】 题目:计算字符串中子串出现的次数 【程序50】 题目:有五个学生,每个学生有3门课的成绩,从键盘输入以上数据(包括学生号,姓名,三门课成绩),计算出平均成绩,况原有的数据和计算出的平均分数存放在磁盘文件"stud"中。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值