package com.greatest.Array;
import java.util.Scanner;
public class ti {
// 1.一个数组 ,让每个元素去除第一个元素 ,得到的商作为被除数所在的位置
public static void main(String[] args) {
int[] arr = new int[] { 12, 34, 1, 45, -564, -56, 2 };
// for(int i=0;i<arr.length;i++){
// arr[i]=arr[i]/arr[0];
// }
for (int i = arr.length - 1; i >= 0; i--) {
arr[i] = arr[i] / arr[0];
}
for (int i = 0; i < arr.length; i++) {
System.out.println(arr[i]);
}
}
}
class Test1 {
public static void main(String[] args) {
//2. 编写程序 :从键盘上读入一个学生的成绩 存放在变量score中
// 根据score对应的值输出所对应成绩的等级
Scanner sc = new Scanner(System.in);
for (;;) {
System.out.println("请输入成绩:");
int score = sc.nextInt();
char level;
if (score >= 90) {
level = 'A';
} else if (score >= 70) {
level = 'B';
} else if (score >= 60) {
level = 'C';
} else {
level = 'D';
}
System.out.println("等级为:" + level);
if (score == 0) {
return;
}
}
}
}
class test2 {
public static void main(String[] args) {
int x = 4;
int y = 1;
if (x > 2) {
}
}
}
class Yanghuisanjiao {
/*
* 3.杨辉三角
* 1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1
1 7 21 35 35 21 7 1
1 8 28 56 70 56 28 8 1
1 9 36 84 126 126 84 36 9 1
*/
public static void main(String[] args) {
int[][] yanghui = new int[10][];
// 1.初始化二维数组
for (int i = 0; i < yanghui.length; i++) {
yanghui[i] = new int[i + 1];
}
// 2.显示的为每个元素赋值
for (int i = 0; i < yanghui.length; i++) {
for (int j = 0; j < yanghui.length; j++) {
yanghui[i][0] = yanghui[i][i] = 1;// 为外边的赋值
if (i > 1 && j > 0 && j < i) {
yanghui[i][j] = yanghui[i - 1][j] + yanghui[i - 1][j - 1];
}
}
}
// 3.遍历二维数组
for (int i = 0; i < yanghui.length; i++) {
for (int j = 0; j < yanghui[i].length; j++) {
System.out.print(yanghui[i][j] + "\t");
}
System.out.println();
}
}
}
class TestArray {
//4. 金额转换 如:105600123 => 壹亿零仟伍佰陆拾零万零仟壹佰贰拾叁圆整
private static final char[] untits = new char[] { '圆', '拾', '佰', '仟', '万', '拾', '佰', '仟', '亿' };
private static final char[] data = new char[] { '零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖' };
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.println("请输入金额:");
int money = s.nextInt();
String strMoney = convert(money);
System.out.println(strMoney);
}
public static String convert(int money) {
StringBuffer sb = new StringBuffer("整");
int init = 0;
while (money != 0) {
sb.insert(0, untits[init++]);
int number = money % 10;
sb.insert(0, data[number]);
money /= 10;
}
return sb.toString();
}
}
class StudentScore1{
/*
* 5.从键盘读入学生成绩,找出最高分,并输出学生成绩等级。 成绩>=最高分-10 等级为’A’ 成绩>=最高分-20 等级为’B’ 成绩>=最高分-30
* 等级为’C’ 其余 等级为’D’
*
* 提示:先读入学生人数,根据人数创建int数组,存放学生成绩。
*
*/
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入学生的个数 ");
int count = sc.nextInt();
int[] scores = new int[count];
int maxsco = 0;
System.out.println("请输入" + count + "个学生 的成绩");
for (int i = 0; i < scores.length; i++) {
int score = sc.nextInt();
scores[i] = score;// 给数组赋值
if (scores[i] > maxsco) {// 找最大的成绩
maxsco = scores[i];
}
}
System.out.println("最高分为" + maxsco);
for (int i = 0; i < scores.length; i++) {
char level;
if (scores[i] >= maxsco - 10) {
level = 'A';
} else if (scores[i] >= maxsco - 20) {
level = 'B';
} else if (scores[i] >= maxsco - 30) {
level = 'C';
} else {
level = 'D';
}
System.out.println("Student" + i + "score is" + scores[i] + "grade is" + level);
}
}
}
class WanShu {
//6.一个数如果恰好等于他的因子之和 这个数就成为完数
//列如 6=1+2+3
public static void main(String[] args) {
int factor=0;
for(int i=1;i<=1000;i++){
for(int j=1;j<i;j++){
if(i%j==0){
factor+=j;//满足累加
}
}
if(i==factor){
System.out.println(i);
}
factor=0;//重置
}
}
}
class mianshi {
//7.从键盘上输入年 月 日 判断这天是当年的第几天
public static void main(String [] args ){
Scanner sc=new Scanner(System.in);
System.out.println("请输入年");
int year=sc.nextInt();
System.out.println("请输入月:");
int month=sc.nextInt();
System.out.println("请输入天");
int day=sc.nextInt();
int num=0;
int yearday=0;
switch(month){
case 12:
num+=30;
case 11:
num+=31;
case 10:
num+=30;
case 9:
num+=31;
case 8:
num+=31;
case 7:
num+=30;
case 6:
num+=31;
case 5:
num+=30;
case 4:
num+=31;
case 3:
if(year%4==0&& year%100!=0||year%400==0){
num+=29;
yearday=366;
System.out.println("闰年");
}else{
num+=28;
yearday=365;
System.out.println("平年");
}
case 2:
num+=31;
case 1:
num+=day;
}System.out.println(year+"年"+month+"月"+day+"是今年的第"+num+"天,今年还剩"+(yearday-num )+"天。");
}
}