不少程序员都会碰到的三个面试题
来源:互联网 发布:网络现在最火的歌 编辑:程序博客网 时间:2024/04/29 13:20
面试问题如下:
1. 求从10到100中能被3或5整除的数的和
int sum = 0; for(int i = 10; i <= 100; i++) if( i % 3 == 0 || i % 5 == 0) sum += i; System.out.println(sum);
2. 将一个字符串逆序,不要使用反转函数
String message = \"he saw a racecar\"; StringBuilder rev = new StringBuilder(); for(int i = message.length()-1; i >= 0; i--) rev.append(message.charAt(i)); System.out.println(rev.toString());
3. 反转一个栈
<pre class="\"brush:" java;="" gutter:="" true\"="" style="white-space: pre-wrap; word-wrap: break-word; line-height: 32px; background-color: rgb(255, 255, 255);">import java.util.*;public class MyProgram extends com.ktbyte.submit.Coder { public static void main(String[] args) { Stack items = new Stack(); items.push(\"he\"); //he is at the bottom of the stack items.push(\"saw\"); items.push(\"a\"); items.push(\"racecar\"); reverseStack(items); //now he is at the top //print in order pushed: while(items.size()>0) System.out.println(items.pop()); } public static void reverseStack(Stack stack) { Queue rev = new LinkedList(); while(stack.size()>0) rev.offer(stack.pop()); while(rev.size()>0) stack.push(rev.poll()); }} 0 0
- 不少程序员都会碰到的三个面试题
- 不少程序员都会碰到的三个面试题
- 不少程序员都会碰到的三个面试题
- 不少程序员都会碰到的三个面试题
- 不少程序员都会碰到的三个面试题
- 不少程序员都会碰到的三个面试题
- 不少程序员都会碰到的三个面试题
- 不少程序员都会碰到的三个面试题
- 不少程序员都会碰到的三个面试题
- 不少程序员都会碰到的三个面试题
- 不少程序员都会碰到的三个面试题
- 不少程序员都会碰到的三个面试题
- 不少程序员都会碰到的三个面试题
- 不少程序员都会碰到的三个面试题
- 不少程序员都会碰到的三个面试题
- 不少程序员都会碰到的三个面试题:如果你只想获取一些面试准备经验,那么你可以直接跳到文章的最后部分
- 很多程序员都会碰到的面试题
- 经常碰到的面试题
- Linux 双链表 list_for_each_entry 实现
- 用AT89S52控制单个舵机程序
- 寻路NavMeshAgent
- 如何利用Google成为一个更好的程序员
- centos 6.x 初始化配置,静态IP配置,IPV6禁止等
- 不少程序员都会碰到的三个面试题
- 【C#】C#中的位操作
- 抽象类
- Eclipse好使但部署到weblogic出现ClientInstanceInvocationHandler错误
- Android设置壁纸
- gamma校正及仿真
- cyc 的面试宝典之(面试1(java se 基础篇))
- Unity 使用LineRenderer 画箭头
- python编程常用模板总结