机房作业2

1.

import java.util.*;

public class Homejava1 {

 public static void main(String[] args) {              int i,n,m;              int s[]=new int[4];    Scanner sc=new Scanner(System.in);              for(i=0;i<4;i++)               s[i]=sc.nextInt();              for(i=0;i<4;i++)                  System.out.println("s[i]="+s[i]);              for(i=3;i>=0;i--)                  System.out.println("s[i]="+s[i]);              n=0;              m=0;              for(i=1;i<4;i++){               if(s[n]<s[i])                n=i;               if(s[m]>s[i])                m=i;              }              System.out.println("最大值"+s[n]);              System.out.println("最小值"+s[m]);  }

}

 

2.

import java.lang.reflect.Array;

public class Homejava2 {

 public static void main(String[] args) {   int s[]={8,5,6,9,7,4,1,2,3,10};   Arrays.sort(s);   for(int i=0;i<10;i++)           System.out.println("s[i]="+s[i]);  } }

 

3.

public class Homejava3 {

 public static void main(String[] args) {   int n=0;   int s[]={85,74,96,35,16,85,25,65,85,87};   for(int i=0;i<10;i++)     if(s[i]<60)       n++;   System.out.println("n="+n);

 }

}

 

4.

import java.util.*;

public class Homejava4 {

 public static void main(String[] args) {   int n=0;   String s;   Scanner sc=new Scanner(System.in);         s=sc.nextLine();         char ch[]=s.toCharArray();         for(int i=0;i<4;i++){          n=n*10+ch[i]-'0';          System.out.println(n);         }         if(n==4310)          System.out.println("是长沙身份证");         else          System.out.println("不是长沙身份证");         if(ch[16]%2==0)          System.out.println("是女生");         else          System.out.println("是男生");  }

}

 

posted @ 2019-04-10 14:40  畅大哥  阅读(142)  评论(1编辑  收藏  举报