class Demo3 {
public static void main(String[] args)
{
int [] arr ={3553,2000,2332,1166,3000,8228,5000,3773,8000,8888,6666};
selectSort(arr);
int count = 0;
for(int x=0;x<arr.length;x++) {
int ge=arr[x]%10;
int shi=arr[x]/10%10;
int bai=arr[x]/100%10;
int qian=arr[x]/1000;
if(ge+bai==shi+qian) {
System.out.println(arr[x]);
count++;
}
}
System.out.println("count="+count);
}
public static void selectSort(int [] arr) {
for(int x=0;x<arr.length-1;x++) {
for(int y=x;y<arr.length;y++) {
if(arr[x]<arr[y]) {
int temp = arr[x] ;
arr[x] = arr[y];
arr[y] = temp;
}}}}} |
|