Java经典面试编程设计题(含答案)

上传人:e****s 文档编号:1347896 上传时间:2017-06-08 格式:DOC 页数:6 大小:35KB
返回 下载 相关 举报
Java经典面试编程设计题(含答案)_第1页
第1页 / 共6页
Java经典面试编程设计题(含答案)_第2页
第2页 / 共6页
Java经典面试编程设计题(含答案)_第3页
第3页 / 共6页
Java经典面试编程设计题(含答案)_第4页
第4页 / 共6页
Java经典面试编程设计题(含答案)_第5页
第5页 / 共6页
点击查看更多>>
资源描述

《Java经典面试编程设计题(含答案)》由会员分享,可在线阅读,更多相关《Java经典面试编程设计题(含答案)(6页珍藏版)》请在金锄头文库上搜索。

1、职坐标 1、程序实现目标: 输入一个字符串,将其各个字符对应的 ASCII 值加 5 后,输出结果。程序要求:该字符串只包含小写字母,若其值加 5 后的字符值大于 z,将其转换成从 a 开始的字符。1. package com.iotex; 2. public class StringParseASCII 3. 4. public static void main(String args) 5. System.out.print(stringParseASCII(abx); 6. 7. 8. public static String stringParseASCII(String str)

2、9. StringBuffer result = new StringBuffer(); 10. char tmp; 11. for(int i = 0;i z) 14. result.append(a); 15. else 16. result.append(tmp); 17. 18. 19. 20. return result.toString(); 21. 22. 23. 1. package com.iotex; 2. 3. public class StringParseASCII 4. 5. public static void main(String args) 6. Syste

3、m.out.print(stringParseASCII(abx); 7. 8. 9. public static String stringParseASCII(String str) 10. StringBuffer result = new StringBuffer(); 11. char tmp; 12. for(int i = 0;i z) 15. result.append(a); 16. else 17. result.append(tmp); 职坐标 18. 19. 20. 21. return result.toString(); 22. 23. 24. 2、程序实现目标:

4、求一个整型数组中元素的平均值,并统计其中大于和小于此平均值的元素的个数。程序要求:输入:整型数组中的元素个数及各个元素。输出:整型数组中元素的平均值,大于和小于此平均值的元素的个数。1. package com.iotex; 2. 3. import java.util.Arrays; 4. 5. /* 6. * 7. * author iotex 8. * 2017-5-7 下午 11:06:29 9. *2.程序实现目标:求一个整型数组中元素的平均值,并统计其中大于和小于此平均值的元素的个数。 10. *程序要求: 11. * 输入:整型数组中的元素个数及各个元素。 12. * 输出:整型

5、数组中元素的平均值,大于和小于此平均值的元素的个数。 13. */ 14. public class CountAvg 15. public static void main(String args) 16. int array = 1,23,4,13,6; 17. System.out.println(Arrays.toString(array)+的平均值: +avg(array)+n + 18. 大于和小于平均值元素的个数分别为:+Arrays.toString(countAvg(array); 19. 20. 21. public static int countAvg(int arra

6、y) 22. int gt = 0; /grater than 23. int lt = 0; /less than 24. int result = 0,0; 25. int average = avg(array); 26. for(int i = 0;iaverage) 28. gt+; 29. else if(arrayiaverage) 19. gt+; 20. else if(arrayiiotex 6. * 2017-5-7 下午 11:35:13 7. *3、手动输入一个存储整数的数组,要求输出数组里面的 2 个最大值。 8. * 实例: 9. * 输入:1,2,5,9,84,

7、3,2 10. * 输出:84,9 11. */ 12. public class FindMaxTwoNum 13. public static void main(String args) 14. int array = 1,2,5,9,84,3,2; 15. System.out.println(数组+Arrays.toString(array)+里面最大的 2 个数为:); 16. findMaxTwoNum(array); 17. /方法二: 18. / 19. 20. public static void findMaxTwoNum(int array) 21. int result = 0,0; 22. for(int i = 0 ;iarray.length;i+) 职坐标 23. for(int j = 0;jarray.length-i-1;j+) 24. if(arrayjarrayj+1) 25. int tmp; 26. tmp = arrayj; 27. arrayj = arrayj+1; 28. arrayj+1 = tmp; 29. 30. 31. 32. 33. System.out.println(array0+、+array1); 34. 35. 36.

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 商业/管理/HR > 物业管理

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号