HW4.41

本文介绍了一个简单的Java程序,该程序用于接收用户输入的一系列整数,并找出这些整数中的最大值及其出现次数。通过使用Scanner类读取控制台输入,程序能够持续接收数值直到输入为0,然后输出最大值及其出现频率。

 

 1 import java.util.Scanner;
 2 
 3 public class Solution
 4 {
 5     public static void main(String[] args)
 6     {
 7         Scanner input = new Scanner(System.in);
 8 
 9         System.out.print("Enter numbers: ");
10 
11         int max = 0;
12         int count = 0;
13         int number;
14 
15         while(true)
16         {
17             number = input.nextInt();
18             if(number == 0)
19                 break;
20             if(number > max)
21             {
22                 max = number;
23                 count = 0;
24             }
25             if(number == max)
26                 count++;
27         }
28 
29         input.close();
30 
31         System.out.println("The largest number is " + max);
32         System.out.println("The occurence count of the largest number is " + count);
33     }
34 }

 

转载于:https://www.cnblogs.com/wood-python/p/5787917.html

root@ER7206:/# dmesg | grep -i init [ 0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off [ 0.000000] Memory: 490968K/520512K available (7358K kernel code, 480K rwdata, 2428K rodata, 448K init, 292K bss, 29544K reserved, 0K cma-reserved) [ 0.039042] ASID allocator initialised with 65536 entries [ 0.100364] devtmpfs: initialized [ 0.122578] pinctrl core: initialized pinctrl subsystem [ 0.155021] SCSI subsystem initialized [ 0.187950] Bluetooth: HCI device and connection manager initialized [ 0.194340] Bluetooth: HCI socket layer initialized [ 0.199244] Bluetooth: L2CAP socket layer initialized [ 0.204326] Bluetooth: SCO socket layer initialized [ 0.560407] [mtk_hw_init] reset_lock:0, force:0 [ 0.564993] [mtk_hw_init] execute fe cold reset [ 0.786175] device-mapper: ioctl: 4.41.0-ioctl (2019-09-16) initialised: dm-devel@redhat.com [ 1.321082] Run /sbin/init as init process [ 2.319615] random: crng init done [ 12.233605] Initializing XFRM netlink socket [ 12.342839] fuse: init (API version 7.31) [ 12.418118] kspeed_init [ 12.422315] balance route match init success! [ 12.435133] ipt_safesearch_target: Unknown symbol spinlock_init (err -2) [ 12.460726] ipt_safesearch_target: Unknown symbol spinlock_init (err -2) [ 12.494040] ipt_safesearch_target: Unknown symbol spinlock_init (err -2) [ 12.534731] ipt_safesearch_target: Unknown symbol spinlock_init (err -2) [ 12.566091] ipt_safesearch_target: Unknown symbol spinlock_init (err -2) [ 12.588755] ipt_safesearch_target: Unknown symbol spinlock_init (err -2) [ 12.609291] ipt_safesearch_target: Unknown symbol spinlock_init (err -2) [ 12.632672] ipt_safesearch_target: Unknown symbol spinlock_init (err -2) [ 12.653287] ipt_safesearch_target: Unknown symbol spinlock_init (err -2) [ 12.691103] ipt_safesearch_target: Unknown symbol spinlock_init (err -2) [ 12.878700] ipt_safesearch_target: Unknown symbol spinlock_init (err -2) [ 12.936652] ipt_safesearch_target: Unknown symbol spinlock_init (err -2) [ 12.977988] ipt_safesearch_target: Unknown symbol spinlock_init (err -2) [ 40.960724] /home/tplink/jenkins_ep/workspace/GW/SDNC6_2_ALL/omada_gateway/build_dir/target-aarch64_cortex-a53_musl-1.2.4-er7206_un_v2/fqdn/fqdn_core.c:562 InitHashFqdn succ. [ 56.745013] init special_route module finish, nf_conntrack_max=[150000]. [ 56.754762] special route target init success! [ 57.743596] tp_domain start init 这是什么系统
08-28
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值