---恢复内容开始---
package 统计成绩;
import java.util.Scanner;//输入输出函数定义
public class Sum {
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
int[] cs = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};//存放十个同学的c++成绩并赋初值为0 为下边求和做准备
int[] ss = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};//存放十个同学的数据结构成绩并赋初值为0 为下边求和做准备
int[] hs = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};//存放十个同学的汇编成绩并赋初值为0 为下边求和做准备
import java.util.Scanner;//输入输出函数定义
public class Sum {
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
int[] cs = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};//存放十个同学的c++成绩并赋初值为0 为下边求和做准备
int[] ss = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};//存放十个同学的数据结构成绩并赋初值为0 为下边求和做准备
int[] hs = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};//存放十个同学的汇编成绩并赋初值为0 为下边求和做准备
for (int i=0; i<10; i++)//循环 一个个输入进去
{
System.out.print("请输入第" + (i+1) + "位学生的c++成绩:");
cs[i] = scan.nextInt();
System.out.print("请输入第" + (i+1) + "位学生的数据结构成绩:");
ss[i] = scan.nextInt();
System.out.print("请输入第" + (i+1) + "位学生的汇编成绩:");
hs[i] = scan.nextInt();
}
{
System.out.print("请输入第" + (i+1) + "位学生的c++成绩:");
cs[i] = scan.nextInt();
System.out.print("请输入第" + (i+1) + "位学生的数据结构成绩:");
ss[i] = scan.nextInt();
System.out.print("请输入第" + (i+1) + "位学生的汇编成绩:");
hs[i] = scan.nextInt();
}
for (int j=0; j<10; j++)//循环 一个个显示输出
{
System.out.println("学号 c++ 数据结构 汇编语言 总分 平均分");//显示第一行
System.out.println((j+1) + " " + cs[j] + " " + ss[j] +" " + hs[j] + " " + (cs[j]+ss[j]+hs[j]) + " " + (cs[j]+ss[j]+hs[j])/3);//显示第二行 分别对应第一行显示
}
{
System.out.println("学号 c++ 数据结构 汇编语言 总分 平均分");//显示第一行
System.out.println((j+1) + " " + cs[j] + " " + ss[j] +" " + hs[j] + " " + (cs[j]+ss[j]+hs[j]) + " " + (cs[j]+ss[j]+hs[j])/3);//显示第二行 分别对应第一行显示
}
scan.close();
}
}
}
}
显示结果
---恢复内容结束---
package 统计成绩;
import java.util.Scanner;
public class Sum {
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
int[] cs = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int[] ss = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int[] hs = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
import java.util.Scanner;
public class Sum {
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
int[] cs = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int[] ss = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int[] hs = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
for (int i=0; i<10; i++)
{
System.out.print("请输入第" + (i+1) + "位学生的c++成绩:");
cs[i] = scan.nextInt();
System.out.print("请输入第" + (i+1) + "位学生的数据结构成绩:");
ss[i] = scan.nextInt();
System.out.print("请输入第" + (i+1) + "位学生的汇编成绩:");
hs[i] = scan.nextInt();
}
{
System.out.print("请输入第" + (i+1) + "位学生的c++成绩:");
cs[i] = scan.nextInt();
System.out.print("请输入第" + (i+1) + "位学生的数据结构成绩:");
ss[i] = scan.nextInt();
System.out.print("请输入第" + (i+1) + "位学生的汇编成绩:");
hs[i] = scan.nextInt();
}
for (int j=0; j<10; j++)
{
System.out.println("学号 c++ 数据结构 汇编语言 总分 平均分");
System.out.println((j+1) + " " + cs[j] + " " + ss[j] +" " + hs[j] + " " + (cs[j]+ss[j]+hs[j]) + " " + (cs[j]+ss[j]+hs[j])/3);
}
{
System.out.println("学号 c++ 数据结构 汇编语言 总分 平均分");
System.out.println((j+1) + " " + cs[j] + " " + ss[j] +" " + hs[j] + " " + (cs[j]+ss[j]+hs[j]) + " " + (cs[j]+ss[j]+hs[j])/3);
}
scan.close();
}
}
}
}