1.用class1Grade数组保存第一组数据,用class2Grade保存第二组数据,每一组均是5个int型数据。
2.用gradeCount数组保存合并后的数组,并将该数组元素按照从小到大的顺序输出
代码如下;
下面展示一些
内联代码片
。
// A code block
var foo = 'bar';
// An highlighted block
package step2;
import java.util.Scanner;
import java.util.Arrays;
public class MarkStatistics {
public static void main(String[] args)
{
Scanner scanner = new Scanner(System.in);
int[] class1Grade = new int[5];
int[] class2Grade = new int[5];
int[] gradeCount = new int[class1Grade.length + class2Grade.length];
/********** Begin *********/
for(int i=0;i<5;i++)
{
int s=scanner.nextInt();
class1Grade[i]=s;
}
for(int i=0;i<5;i++)
{
int s=scanner.nextInt();
class2Grade[i]=s;
}
System.arraycopy(class1Grade,0,gradeCount,0,class1Grade.length);
System.arraycopy(class2Grade,0,gradeCount,class1Grade.length,class2Grade.length);
Arrays.sort(gradeCount);
/********** End *********/
for (int i = 0; i < gradeCount.length; i++)
{
System.out.print(gradeCount[i]);
if (i != gradeCount.length - 1)
{
System.out.print(' ');
}
}
}
}