查找第二大值
2015-10-11 00:00
141 查看
public class SecondBig {
public static void main(String[] args) { int a[] = {9,8,7,7,8,8}; int firstB = a[0]; int secondB = a[1]; for(int i = 1; i<a.length; i++){ if(a[i] > firstB){ secondB = firstB; firstB = a[i]; } else if((a[i] < firstB)&&(a[i] > secondB)){ secondB = a[i]; } } if(firstB == secondB){ System.out.println("no secondB"); } else System.out.println("SecondB is " + secondB);
}
}
相关文章推荐
- 递归判断数组递增
- 大数相加
- Eclipse替代ndk-gdb断点调试Android NDK程序
- java枚举之简要
- java之反射构造方法
- java反射之成员变量的反射
- swift中字符串截取方法(substring)
- Linux中变量$#,$@,$0,$1,$2,$*,$$,$?的含义
- opencv3中scharr滤波器
- 随便记录下内容
- mac上的终端里添加mysql命令
- Mac OS X 10.11下如何安装MySQLdb?
- Objective-c self的用法
- [ogre] ogre遇到一些小问题
- apktool反编译
- android反编译
- 关于android4.4及以上版本无法恢复还原短信的问题记录与解决
- java 线程学习笔记(二)
- Oracle提高sql执行效率的心得建议
- ElyarAnwar的Android实战笔记---计算器(二) 分享是最好的记忆