【零基礎(chǔ) 快速學(xué)Java】韓順平 零基礎(chǔ)30天學(xué)會Java
2023-04-09 01:23 作者:莫以潤物細(xì)吾生 | 我要投稿

擴(kuò)容定位:沒老師的好
import java.util.Scanner;
public class dingwei{
public static void main (String[] args){
int[] ding = {10,12,45,90};
Scanner myScanner = new Scanner(System.in);
int n ;
int i ;
int j=0 ;
n = myScanner.nextInt();
for(i=0;i<ding.length;i++){
if (ding[i]-n>0){
j=i;
break;
}
j=ding.length;
}
int ding1[] = new int[ding.length+1];
ding1[j] = n;
for(i=0;i<ding.length;i++){
if(i<j){
ding1[i]=ding[i];
}
else{
ding1[i+1]=ding[i];
}
}
ding =ding1;
for(i=0;i<ding.length;i++){
System.out.print(ding[i]+" ");
}?
}
}
標(biāo)簽: