不少程序员遇到的问题
来源:互联网 发布:家有学霸类似软件 编辑:程序博客网 时间:2024/05/18 02:07
面试问题如下:
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. 反转一个栈
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
- 不少程序员遇到的问题
- 用IIS6架网站的时候遇到不少问题
- 最近遇到问题不少,还真不好解决,记录下来,静下心的时候好好想想
- Error link2001:unresolved external symbol _main ...(不少编程初学者遇到的问题)
- UITableView中奇怪的问题真不少!
- C++ 分割字符串的问题不少啊
- 不少程序员都会碰到的三个面试题
- 不少程序员都会碰到的三个面试题
- 不少程序员都会碰到的三个面试题
- 不少程序员都会碰到的三个面试题
- 不少程序员都会碰到的三个面试题
- 不少程序员都会碰到的三个面试题
- 不少程序员都会碰到的三个面试题
- 不少程序员都会碰到的三个面试题
- 不少程序员都会碰到的三个面试题
- 不少程序员都会碰到的三个面试题
- 不少程序员都会碰到的三个面试题
- 不少程序员都会碰到的三个面试题
- mysql 的安装
- hibernate的工作原理
- Tensorflow 04__:tensorboard的官网教程
- 深度学习之图像修复
- POJ 2002 Squares 笔记
- 不少程序员遇到的问题
- Android系统介绍与框架
- 移动APP崩溃测试用例的设计
- android事件处理机制
- 添加不了artifact
- 大型网站架构演化
- JMeter性能测试基础
- gdb调试多进程和多线程
- Spring MVC中使用Swagger生成API文档