mirror of
https://github.com/Dichgrem/Java.git
synced 2025-12-18 21:31:59 -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 ? "" : " "));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user