7-4学生成绩排序输出
import java.util.*;
class Student implements Comparable<Student>
{
private String name name,id;
private int subject=1;
private int score;
private double sum=0;
Student(String name,String id,int score){
this.name=name;
this.id=id;
this.score=score;}
public String getid(){
return this.id;}
public subjectadd(){
this.subject++;}
publi String getname(){
return this.name;}
public void scoreadd(int score){
this.score =this.score=score;
}
public void sum(){
this.sum=this.score/this.subject;}
public int compareTo(Student o1){
Student one=(Student)o1;
if(this.sum-one.sum!=0)
return(int)(one.sum-this.sum);
else
return this.id.comrareTo(one.id);}}
public css Main{
public static void main(Stirng[] args){
Scanner sc=newScanner (System.in);
List<Student>list=new ArrayList<Student>();
int i,flag=0;
String k;
String[] and=new String[5];
while (sc.hasNext())
{k=sc.next();
and=k.split(",");
if(k.compareTo("exit"==0)
break;
for(i=0;i<list.size();i++)
7--5求交集
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner (System.in);
int m=sc.nextInt();
int []a=new int[m];
int n=sc.nextInt();
int []b=new int[n];
int flag=0;
for(int i=0;i<m;i++){
a[i]=sc.nextInt();}
for(int i=0;i<n;i++){
b[i]=sc.nextInt();}
for (inti=0;i,m;i++){
for (int j=0;j<n;j++){
if (a[i]==b[j]){
flag++;
if(flag==1){
System.out.print(a[j]);}
else
System.out.print(" "+a[i]);
}}}
if(flag==0)
System.out.println("NULL");
}}