mirror of
https://github.com/Dichgrem/Java.git
synced 2025-12-17 04:51:58 -05:00
style:fmt
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package com.study.demo;
|
||||
|
||||
public class Demo {
|
||||
public static void main(String [] args) {
|
||||
System.out.println("HelloWorld!");
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
System.out.println("HelloWorld!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
package com.study.demo;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
// I am 212306206
|
||||
public class test1_type {
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner (System.in);
|
||||
int a = scanner.nextInt();
|
||||
int b = scanner.nextInt();
|
||||
int sum = a + b;
|
||||
System.out.println(a + " + " + b + " = " + sum);
|
||||
scanner.close();
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
int a = scanner.nextInt();
|
||||
int b = scanner.nextInt();
|
||||
int sum = a + b;
|
||||
System.out.println(a + " + " + b + " = " + sum);
|
||||
scanner.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
package com.study.demo;
|
||||
|
||||
public class test2_for {
|
||||
public static void main(String[] args) {
|
||||
int[] numbers = new int[5];
|
||||
for (int i = 0; i < numbers.length; i++) {
|
||||
numbers[i] = i * 10;
|
||||
}
|
||||
|
||||
System.out.print("数组内容: ");
|
||||
for (int i = 0; i < numbers.length; i++) {
|
||||
System.out.print(numbers[i] + " ");
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
int[] numbers = new int[5];
|
||||
for (int i = 0; i < numbers.length; i++) {
|
||||
numbers[i] = i * 10;
|
||||
}
|
||||
}
|
||||
|
||||
System.out.print("数组内容: ");
|
||||
for (int i = 0; i < numbers.length; i++) {
|
||||
System.out.print(numbers[i] + " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
package com.study.demo;
|
||||
|
||||
public class test3_1_99 {
|
||||
public static void main(String[] args) {
|
||||
int[] numbers = new int[99];
|
||||
public static void main(String[] args) {
|
||||
int[] numbers = new int[99];
|
||||
|
||||
for (int i = 0; i < numbers.length; i++) {
|
||||
numbers[i] = i + 1;
|
||||
}
|
||||
|
||||
int sum = 0;
|
||||
for (int i = 0; i < numbers.length; i++) {
|
||||
sum += numbers[i];
|
||||
}
|
||||
|
||||
System.out.println("1+2+...+99 的和 = " + sum);
|
||||
for (int i = 0; i < numbers.length; i++) {
|
||||
numbers[i] = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
int sum = 0;
|
||||
for (int i = 0; i < numbers.length; i++) {
|
||||
sum += numbers[i];
|
||||
}
|
||||
|
||||
System.out.println("1+2+...+99 的和 = " + sum);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
package com.study.demo;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
public class test5 {
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
int a = scanner.nextInt();
|
||||
int b = scanner.nextInt();
|
||||
int c = scanner.nextInt();
|
||||
double pi = 3.1415926535;
|
||||
double area = a * b * c + a * c + (pi * c * c) / 4;
|
||||
System.out.printf("%.3f\n", area / 10000);
|
||||
}
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
int a = scanner.nextInt();
|
||||
int b = scanner.nextInt();
|
||||
int c = scanner.nextInt();
|
||||
double pi = 3.1415926535;
|
||||
double area = a * b * c + a * c + (pi * c * c) / 4;
|
||||
System.out.printf("%.3f\n", area / 10000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,10 @@ package com.study.demo;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class test6 {
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
int n = scanner.nextInt();
|
||||
int result = 1 << n;
|
||||
System.out.println(result);
|
||||
}
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
int n = scanner.nextInt();
|
||||
int result = 1 << n;
|
||||
System.out.println(result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,12 @@ package com.study.demo;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class test7 {
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
int x = scanner.nextInt();
|
||||
int y = scanner.nextInt();
|
||||
int startYear = 2016, startMonth = 8;
|
||||
int totalMonths = (x - startYear) * 12 + y - startMonth + 1;
|
||||
System.out.println(totalMonths);
|
||||
}
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
int x = scanner.nextInt();
|
||||
int y = scanner.nextInt();
|
||||
int startYear = 2016, startMonth = 8;
|
||||
int totalMonths = (x - startYear) * 12 + y - startMonth + 1;
|
||||
System.out.println(totalMonths);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,17 +3,17 @@ package com.study.demo;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class test8 {
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
int x = scanner.nextInt();
|
||||
int k = scanner.nextInt();
|
||||
int a = x / 1000 % k;
|
||||
int b = x / 100 % 10 % k;
|
||||
int c = x / 10 % 10 % k;
|
||||
int d = x % 10 % k;
|
||||
System.out.print(a);
|
||||
System.out.print(b);
|
||||
System.out.print(c);
|
||||
System.out.println(d);
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
int x = scanner.nextInt();
|
||||
int k = scanner.nextInt();
|
||||
int a = x / 1000 % k;
|
||||
int b = x / 100 % 10 % k;
|
||||
int c = x / 10 % 10 % k;
|
||||
int d = x % 10 % k;
|
||||
System.out.print(a);
|
||||
System.out.print(b);
|
||||
System.out.print(c);
|
||||
System.out.println(d);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,20 +3,20 @@ package com.study.demo;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class test3_1 {
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
int n = scanner.nextInt();
|
||||
int[] arr = new int[n];
|
||||
for (int i = 0; i < n; i++) {
|
||||
arr[i] = scanner.nextInt();
|
||||
}
|
||||
for (int i = 0; i < n / 2; i++) {
|
||||
int temp = arr[i];
|
||||
arr[i] = arr[n - 1 - i];
|
||||
arr[n - 1 - i] = temp;
|
||||
}
|
||||
for (int i = 0; i < n; i++) {
|
||||
System.out.print(arr[i] + (i == n - 1 ? "" : " "));
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
int n = scanner.nextInt();
|
||||
int[] arr = new int[n];
|
||||
for (int i = 0; i < n; i++) {
|
||||
arr[i] = scanner.nextInt();
|
||||
}
|
||||
for (int i = 0; i < n / 2; i++) {
|
||||
int temp = arr[i];
|
||||
arr[i] = arr[n - 1 - i];
|
||||
arr[n - 1 - i] = temp;
|
||||
}
|
||||
for (int i = 0; i < n; i++) {
|
||||
System.out.print(arr[i] + (i == n - 1 ? "" : " "));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,21 +3,21 @@ package com.study.demo;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class test3_2 {
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
int n = scanner.nextInt();
|
||||
int[] a = new int[n];
|
||||
int[] b = new int[n];
|
||||
for (int i = 0; i < n; i++) {
|
||||
a[i] = scanner.nextInt();
|
||||
}
|
||||
for (int i = 0; i < n; i++) {
|
||||
b[i] = scanner.nextInt();
|
||||
}
|
||||
int sum = 0;
|
||||
for (int i = 0; i < n; i++) {
|
||||
sum += a[i] * b[i];
|
||||
}
|
||||
System.out.println(sum);
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
int n = scanner.nextInt();
|
||||
int[] a = new int[n];
|
||||
int[] b = new int[n];
|
||||
for (int i = 0; i < n; i++) {
|
||||
a[i] = scanner.nextInt();
|
||||
}
|
||||
for (int i = 0; i < n; i++) {
|
||||
b[i] = scanner.nextInt();
|
||||
}
|
||||
int sum = 0;
|
||||
for (int i = 0; i < n; i++) {
|
||||
sum += a[i] * b[i];
|
||||
}
|
||||
System.out.println(sum);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,23 +3,23 @@ package com.study.demo;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class test3_3 {
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
int n = scanner.nextInt();
|
||||
int[] arr = new int[n];
|
||||
for (int i = 0; i < n; i++) {
|
||||
arr[i] = scanner.nextInt();
|
||||
}
|
||||
int maxLen = 1, currentLen = 1;
|
||||
for (int i = 1; i < n; i++) {
|
||||
if (arr[i] == arr[i - 1]) {
|
||||
currentLen++;
|
||||
} else {
|
||||
maxLen = Math.max(maxLen, currentLen);
|
||||
currentLen = 1;
|
||||
}
|
||||
}
|
||||
maxLen = Math.max(maxLen, currentLen);
|
||||
System.out.println(maxLen);
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
int n = scanner.nextInt();
|
||||
int[] arr = new int[n];
|
||||
for (int i = 0; i < n; i++) {
|
||||
arr[i] = scanner.nextInt();
|
||||
}
|
||||
int maxLen = 1, currentLen = 1;
|
||||
for (int i = 1; i < n; i++) {
|
||||
if (arr[i] == arr[i - 1]) {
|
||||
currentLen++;
|
||||
} else {
|
||||
maxLen = Math.max(maxLen, currentLen);
|
||||
currentLen = 1;
|
||||
}
|
||||
}
|
||||
maxLen = Math.max(maxLen, currentLen);
|
||||
System.out.println(maxLen);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,21 +3,21 @@ package com.study.demo;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class test3_4 {
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
int n = scanner.nextInt();
|
||||
int m = scanner.nextInt();
|
||||
int[][] image = new int[n][m];
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (int j = 0; j < m; j++) {
|
||||
image[i][j] = scanner.nextInt();
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < m; j++) {
|
||||
for (int i = n - 1; i >= 0; i--) {
|
||||
System.out.print(image[i][j] + (i == 0 ? "" : " "));
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
int n = scanner.nextInt();
|
||||
int m = scanner.nextInt();
|
||||
int[][] image = new int[n][m];
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (int j = 0; j < m; j++) {
|
||||
image[i][j] = scanner.nextInt();
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < m; j++) {
|
||||
for (int i = n - 1; i >= 0; i--) {
|
||||
System.out.print(image[i][j] + (i == 0 ? "" : " "));
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,32 +3,32 @@ package com.study.demo;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class test3_5 {
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
int n = scanner.nextInt();
|
||||
int[] t = new int[n - 1];
|
||||
int[] s = new int[n];
|
||||
for (int i = 0; i < n - 1; i++) {
|
||||
t[i] = scanner.nextInt();
|
||||
}
|
||||
for (int i = 0; i < n; i++) {
|
||||
s[i] = scanner.nextInt();
|
||||
}
|
||||
int x = scanner.nextInt();
|
||||
int y = scanner.nextInt();
|
||||
|
||||
int total = 0;
|
||||
if (x < y) {
|
||||
for (int i = x - 1; i < y - 1; i++) {
|
||||
total += s[i] + t[i];
|
||||
}
|
||||
total += s[y - 1];
|
||||
} else {
|
||||
for (int i = x - 1; i >= y; i--) {
|
||||
total += s[i] + (i > 0 ? t[i - 1] : 0);
|
||||
}
|
||||
total += s[y - 1];
|
||||
}
|
||||
System.out.println(total);
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
int n = scanner.nextInt();
|
||||
int[] t = new int[n - 1];
|
||||
int[] s = new int[n];
|
||||
for (int i = 0; i < n - 1; i++) {
|
||||
t[i] = scanner.nextInt();
|
||||
}
|
||||
for (int i = 0; i < n; i++) {
|
||||
s[i] = scanner.nextInt();
|
||||
}
|
||||
int x = scanner.nextInt();
|
||||
int y = scanner.nextInt();
|
||||
|
||||
int total = 0;
|
||||
if (x < y) {
|
||||
for (int i = x - 1; i < y - 1; i++) {
|
||||
total += s[i] + t[i];
|
||||
}
|
||||
total += s[y - 1];
|
||||
} else {
|
||||
for (int i = x - 1; i >= y; i--) {
|
||||
total += s[i] + (i > 0 ? t[i - 1] : 0);
|
||||
}
|
||||
total += s[y - 1];
|
||||
}
|
||||
System.out.println(total);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user