HW6.17
2024-08-26 15:59:03
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter count of numbers: "); int count = input.nextInt(); double[] number = new double[count]; for(int i = 0; i < count; i++) number[i] = input.nextDouble(); input.close(); for(double i: number) System.out.print(i + " "); System.out.println(); selectSort(number); for(double i: number) System.out.print(i + " "); } public static void selectSort(double[] array) { double maxValue, temp; int index; for(int i = array.length - 1; i > 0; i--) { maxValue = array[i]; index = i; for(int j = i - 1; j >= 0; j--) if(array[j] > maxValue) { maxValue = array[j]; index = j; } if(maxValue > array[i]) { temp = array[i]; array[i] = array[index]; array[index] = temp; } } } }
最新文章
- 【原创】Kafka Consumer多线程实例
- 来自沪江、滴滴、蘑菇街架构师的 Docker 实践分享
- uart与usart
- Cow Exhibition_背包(负数情况)
- fineui框架
- poj 2828 Buy Tickets (线段树(排队插入后输出序列))
- [原博客] POJ 2975 Nim 统计必胜走法个数
- android——ImageLoader添加缓存
- SQL如何合并查询结果
- 【Spring】详解Spring中Bean的加载
- Python 简单聊天室
- java Domj4读取xml文件加强训练案例
- MVVM数据代理
- 【ASP.NET Core快速入门】(十四)MVC开发:UI、 EF + Identity实现、注册实现、登陆实现
- python网络编程(图片传输)
- python3 第三十章 - 内置函数之Dictionary相关
- [THUWC2017] 在美妙的数学王国畅游
- gethostbyname用法
- ROS 可视化(一): 发布PointCloud2点云数据到Rviz
- 字符串匹配的Boyer-Moore(BM)算法