标签:res ann ring .com str pre imp har 分享图片
public class Array1 { public static void main(String[] args){ Pritimive d=new Pritimive(); for (int i=0;i<d.t.length;i++){ System.out.println(d.t[i]); } d.t[0]=true; d.t[1]=true; d.t[2]=true; for (int j=0;j<d.t.length;j++){ System.out.println(d.t[j]); } } } class Pritimive{ boolean[] t=new boolean[3]; }
import java.util.Scanner; public class w { public static void main(String[] args){ //从键盘输入学生的个数 Scanner s=new Scanner(System.in); System.out.println("请输入学生人数:"); int count=s.nextInt();//写入学生个数 System.out.println("请输入"+count+"个成绩:"); //定义一个数组存储分数 int[] scores=new int[count]; //定义最高分 int maxscore=0; //找到最高分 for (int i=0;i< scores.length;i++){ int score=s.nextInt();//写入学生成绩 scores[i]=score; if (scores[i]>maxscore){ maxscore=scores[i]; } } //输出最高分 System.out.println("最高分是:"); System.out.println(maxscore); //输出学生成绩 for (int i=0;i<scores.length;i++){ char grade; if (scores[i]>=maxscore-10){ grade=‘A‘; }else if (scores[i]>=maxscore-20){ grade=‘B‘; }else if (scores[i]>=maxscore-30){ grade=‘C‘; }else{ grade=‘D‘; } System.out.println("student "+i+" score is "+scores[i]+" grade is "+grade); } } }
标签:res ann ring .com str pre imp har 分享图片
原文地址:https://www.cnblogs.com/KeepCalmAndNeverSayNever/p/10099845.html