牛客编程题(一)
//https://www.nowcoder.com/practice/ebe941260f8c4210aa8c17e99cbc663b?tpId=37&&tqId=21292&rp=1&ru=/ta/huawei&qru=/ta/huawei/question-ranking
import java.util.Arrays;
import java.util.Scanner;
public class Main0 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()) {
int r = sc.nextInt();
int c = sc.nextInt();
int n = sc.nextInt();
int[][] result = new int[r][n];
int array1[][] = new int[r][c];
int array2[][] = new int[c][n];
for (int i = 0; i < array1.length; i++) {
for (int j = 0; j < array1[i].length; j++) {
array1[i][j] = sc.nextInt();
}
}
for (int i = 0; i < array2.length; i++) {
for (int j = 0; j < array2[i].length; j++) {
array2[i][j] = sc.nextInt();
}
}
for(int i=0;i<array1.length;i++) {//循环第一个矩阵的行数
for(int j=0;j<array2[0].length;j++) {//循环第二个矩阵的列数
for(int k=0;k<array1[0].length;k++) {//循环第一个矩阵的列数,也是第二个矩阵的行数
result[i][j]+=array1[i][k]*array2[k][j];
}
System.out.print(result[i][j]+" ");
}
System.out.println();
}
}
}
}
//https://www.nowcoder.com/practice/4d604603fae94a26b59b7bc18f363bc0?tpId=107&tags=&title=&diffculty=0&judgeStatus=0&rp=1
public class Main2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()) {
int weight = sc.nextInt();
int hight = sc.nextInt();
double BMI = weight/((hight/100.0)*(hight/100.0));
if( BMI<18.5) {
System.out.println("Underweight");
}
if(BMI<=23.9&&BMI>=18.5) {
System.out.println("Normal");
}
if(BMI>23.9&&BMI<=27.9) {
System.out.println("Overweight");
}
if(BMI>27.9)
System.out.println("Obese");
}
}
}
//https://www.nowcoder.com/practice/52c18a3b49a54fc98107fbdde1415f90?tpId=107&&tqId=33326&rp=1&ru=/ta/beginner-programmers&qru=/ta/beginner-programmers/question-ranking
3.
public class Main3 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()) {
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int max1 = Math.max(a, b);
int max2 = Math.max(b, c);
System.out.println(Math.max(max1, max2));
}
}
}
//https://www.nowcoder.com/practice/a8b018667e274af29b5f76a6673450fc?tpId=107&&tqId=33325&rp=1&ru=/ta/beginner-programmers&qru=/ta/beginner-programmers/question-ranking
4.
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int number = sc.nextInt();
if (number % 2 == 0) {
System.out.println("Even");
}
if (number % 2 != 0) {
System.out.println("Odd");
}
}
}
}
//https://www.nowcoder.com/practice/cd052308a1c44a88ad00255f312c3e14?tpId=107&&tqId=33320&rp=1&ru=/ta/beginner-programmers&qru=/ta/beginner-programmers/question-ranking
import java.util.Arrays;
import java.util.Scanner;
public class Main5 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int[] array = new int[sc.nextInt()];
for (int i = 0; i < array.length; i++) {
array[i] = sc.nextInt();
}
Arrays.sort(array);
for(int i=0;i<array.length/2;i++) {
int temp = array[i];
array[i]= array[array.length-i-1];
array[array.length-i-1] = temp;
}
for (int i = 0; i < 5; i++) {
System.out.print(array[i]+" ");
}
}
}
}
//https://www.nowcoder.com/practice/b8f770674ba7468bb0a0efcc2aa3a239?tpId=107&&tqId=33336&rp=1&ru=/ta/beginner-programmers&qru=/ta/beginner-programmers/question-ranking
public class Main6 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()) {
double number1 = sc.nextDouble();
String xx = sc.nextLine();
double number2 = sc.nextDouble();
if(xx!="+"||xx!="*"||xx!="-"||xx!="/") {
System.out.println("Invalid operation!");
}
if(xx=="/"&&number2==0) {
System.out.println("Wrong!Division by zero!");
}
if(xx=="+") {
double res =number1+number2;
System.out.println(number1+"+"+number2+"="+res);
}
if(xx=="-") {
double res =number1-number2;
System.out.println(number1+"-"+number2+"="+res);
}
if(xx=="*") {
double res =number1*number2;
System.out.println(number1+"*"+number2+"="+res);
}
if(xx=="/") {
double res =number1/number2;
System.out.println(number1+"/"+number2+"="+res);
}
}
}
}
//https://www.nowcoder.com/practice/08b28e61ff6345febf09969b3a167f7e?tpId=107&tags=&title=&diffculty=0&judgeStatus=0&rp=1
import java.util.Scanner;
public class Main7 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
double weight = sc.nextDouble();
double hight = sc.nextDouble();
double BMI = weight/(hight*hight);
if(BMI>18.5&&BMI<23.9) {
System.out.println("Normal");
}
else
System.out.println("Abnormal");
}
}
}
//https://www.nowcoder.com/practice/5d7dfd405e5f4e4fbfdff6862c46b751?tpId=107&&tqId=33318&rp=1&ru=/ta/beginner-programmers&qru=/ta/beginner-programmers/question-ranking
8.
import java.util.Scanner;
public class Main8 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
double price = sc.nextDouble();
int mDate = sc.nextInt();
int dDate = sc.nextInt();
int free = sc.nextInt();
if (dDate == 11) {
if (free == 1) {
price = price * 0.7 - 50;
} else {
price = price * 0.7;
}
} else {
if (free == 1) {
price = price * 0.8 - 50;
} else {
price = price * 0.8;
}
}
if(price>0) {
System.out.printf("%.2f",price);
}
else {
System.out.println("0.00");
}
}
}
}
本文地址:https://blog.csdn.net/qq_45874107/article/details/112862624
上一篇: 名词汇总