package Test1;
創(chuàng)新互聯(lián)-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價(jià)比淇縣網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式淇縣網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋淇縣地區(qū)。費(fèi)用合理售后完善,十多年實(shí)體公司更值得信賴。
import java.time.LocalDateTime;
import java.time.Month;
import java.util.IntSummaryStatistics;
import java.util.Scanner;
import java.util.Vector;
public class D {
static String s1 = "";
public static void main(String[] args) {
int day = LocalDateTime.now().getDayOfMonth();
Month month = LocalDateTime.now().getMonth();
int i = 1, i1 = 0;
VectorInteger vector=new Vector();
Scanner scanner = new Scanner(System.in);
while (i day + 1) {
System.out.println("請輸入" + month + "月" + i + "日走的步數(shù)");
try {
i1 = scanner.nextInt();
} catch (Exception e) {
// TODO: handle exception
System.out.println("輸入錯(cuò)誤,請重新輸入");
continue;
}
vector.add(i1);
i++;
}
scanner.close();
IntSummaryStatistics intSummaryStatistics=vector.stream().mapToInt(x-x).summaryStatistics();
int i2=intSummaryStatistics.getMax();
int i3=vector.indexOf(i2);
System.out.println(month+"月走的步數(shù)最多的日期為: "+(i3+1)+"號(hào)");
System.out.println("最多的步數(shù)為: "+i2);
}
}
按照你的要求編寫的Java程序如下
import java.util.Scanner;
public class S{
public static void main(String[] args){
int n=5;
int[] a=new int[n];
System.out.print("請輸入"+n+"個(gè)正整數(shù):");
Scanner sc=new Scanner(System.in);
for(int i=0;in;i++){
a[i]=sc.nextInt();
}
System.out.print("其中的偶數(shù)為:");
for(int i=0;in;i++){
if(a[i]%2==0){
System.out.print(a[i]+" ");
}
}
}
}
public class Demo3 {
public static void main(String[] args) {
byte a =1;
short b=1;
int c = 1;
long d = 1l;
float e=1f;
double f =1;
char g ='1';
boolean h = true;
System.out.println("byte a ="+a);
System.out.println("short b="+b);
System.out.println("int c ="+c);
System.out.println("long d ="+d);
System.out.println("float e="+e);
System.out.println("double f ="+f);
System.out.println("char g ="+g);
System.out.println("boolean h ="+h);
int x=a%b;
long y = c+d;
boolean z=(b==c);
System.out.println("int x="+x);
System.out.println("long y"+y);
System.out.println("boolean z"+z);
}
}