5.8.2
This commit is contained in:
parent
0538cee955
commit
d06c8eb809
BIN
Java Experiments/.DS_Store
vendored
Normal file
BIN
Java Experiments/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
Java Experiments/A/.DS_Store
vendored
Normal file
BIN
Java Experiments/A/.DS_Store
vendored
Normal file
Binary file not shown.
14
Java Experiments/A/A+B Problem.java
Normal file
14
Java Experiments/A/A+B Problem.java
Normal file
@ -0,0 +1,14 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Main
|
||||
{
|
||||
public static void main(String [] args)
|
||||
{
|
||||
Scanner Data = new Scanner(System.in);
|
||||
int a,b;
|
||||
a=Data.nextInt();
|
||||
b= Data.nextInt();
|
||||
System.out.printf("%d",a+b);
|
||||
Data.close();
|
||||
}
|
||||
}
|
18
Java Experiments/A/A+B for Input-Output Practice (I).java
Normal file
18
Java Experiments/A/A+B for Input-Output Practice (I).java
Normal file
@ -0,0 +1,18 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Main
|
||||
{
|
||||
public static void main(String [] args)
|
||||
{
|
||||
Scanner Data = new Scanner(System.in);
|
||||
int a,b;
|
||||
|
||||
while(Data.hasNextInt())
|
||||
{
|
||||
a=Data.nextInt();
|
||||
b=Data.nextInt();
|
||||
|
||||
System.out.printf("%d\n",a+b);
|
||||
}
|
||||
}
|
||||
}
|
21
Java Experiments/A/A+B for Input-Output Practice (III).java
Normal file
21
Java Experiments/A/A+B for Input-Output Practice (III).java
Normal file
@ -0,0 +1,21 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Main
|
||||
{
|
||||
public static void main(String [] args)
|
||||
{
|
||||
Scanner Data = new Scanner(System.in);
|
||||
|
||||
int n,a,b;
|
||||
|
||||
n=Data.nextInt();
|
||||
while(n!=0)
|
||||
{
|
||||
a=Data.nextInt();
|
||||
b=Data.nextInt();
|
||||
|
||||
System.out.printf("%d\n",a+b);
|
||||
n--;
|
||||
}
|
||||
}
|
||||
}
|
27
Java Experiments/A/A+B for Input-Output Practice (IV).java
Normal file
27
Java Experiments/A/A+B for Input-Output Practice (IV).java
Normal file
@ -0,0 +1,27 @@
|
||||
import java.util.*;
|
||||
|
||||
public class Main
|
||||
{
|
||||
public static void main(String [] args)
|
||||
{
|
||||
Scanner Data = new Scanner(System.in);
|
||||
|
||||
int n,a;
|
||||
int sum;
|
||||
while(true)
|
||||
{
|
||||
sum=0;
|
||||
n=Data.nextInt();
|
||||
if(n==0)
|
||||
break;
|
||||
|
||||
while(n!=0)
|
||||
{
|
||||
a=Data.nextInt();
|
||||
sum+=a;
|
||||
n--;
|
||||
}
|
||||
System.out.printf("%d\n",sum);
|
||||
}
|
||||
}
|
||||
}
|
30
Java Experiments/A/A+B for Input-Output Practice (V).java
Normal file
30
Java Experiments/A/A+B for Input-Output Practice (V).java
Normal file
@ -0,0 +1,30 @@
|
||||
import java.util.*;
|
||||
|
||||
public class Main
|
||||
{
|
||||
public static void main(String [] args)
|
||||
{
|
||||
Scanner Data = new Scanner(System.in);
|
||||
|
||||
int n, a;
|
||||
int sum;
|
||||
|
||||
int N;
|
||||
|
||||
N=Data.nextInt();
|
||||
|
||||
while(N!=0)
|
||||
{
|
||||
sum=0;
|
||||
n=Data.nextInt();
|
||||
while(n!=0)
|
||||
{
|
||||
a=Data.nextInt();
|
||||
sum+=a;
|
||||
n--;
|
||||
}
|
||||
System.out.printf("%d\n",sum);
|
||||
N--;
|
||||
}
|
||||
}
|
||||
}
|
25
Java Experiments/A/A+B for Input-Output Practice (VI).java
Normal file
25
Java Experiments/A/A+B for Input-Output Practice (VI).java
Normal file
@ -0,0 +1,25 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Main
|
||||
{
|
||||
public static void main(String [] args)
|
||||
{
|
||||
Scanner Data = new Scanner(System.in);
|
||||
|
||||
int n, a;
|
||||
int sum;
|
||||
|
||||
while(Data.hasNextInt())
|
||||
{
|
||||
sum=0;
|
||||
n=Data.nextInt();
|
||||
while(n!=0)
|
||||
{
|
||||
a=Data.nextInt();
|
||||
sum+=a;
|
||||
n--;
|
||||
}
|
||||
System.out.printf("%d\n",sum);
|
||||
}
|
||||
}
|
||||
}
|
19
Java Experiments/A/A+B for Input-Output Practice (VII).java
Normal file
19
Java Experiments/A/A+B for Input-Output Practice (VII).java
Normal file
@ -0,0 +1,19 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Main
|
||||
{
|
||||
public static void main(String [] args)
|
||||
{
|
||||
Scanner Data = new Scanner(System.in);
|
||||
|
||||
int a,b;
|
||||
|
||||
while(Data.hasNextInt())
|
||||
{
|
||||
a=Data.nextInt();
|
||||
b=Data.nextInt();
|
||||
|
||||
System.out.printf("%d\n\n",a+b);
|
||||
}
|
||||
}
|
||||
}
|
51
Java Experiments/A/A+B for Input-Output Practice.java
Normal file
51
Java Experiments/A/A+B for Input-Output Practice.java
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
Input
|
||||
Input contains an integer N in the first line, and then N lines follow. Each line starts with a integer M, and then M integers follow in the same line
|
||||
Output
|
||||
For each group of input integers you should output their sum in one line, and you must note that there is a blank line between outputs.
|
||||
Sample
|
||||
Input
|
||||
3
|
||||
4 1 2 3 4
|
||||
5 1 2 3 4 5
|
||||
3 1 2 3
|
||||
Output
|
||||
10
|
||||
|
||||
15
|
||||
|
||||
6
|
||||
*/
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Main
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
Scanner in = new Scanner(System.in);
|
||||
|
||||
int N;
|
||||
N = in.nextInt();
|
||||
|
||||
int M;
|
||||
int sum;
|
||||
int t;
|
||||
|
||||
while(N>0)
|
||||
{
|
||||
sum=0;
|
||||
M=in.nextInt();
|
||||
while(M>0)
|
||||
{
|
||||
t=in.nextInt();
|
||||
sum+=t;
|
||||
M--;
|
||||
}
|
||||
System.out.printf("%d\n\n",sum);
|
||||
N--;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
7
Java Experiments/A/Hello World!.java
Normal file
7
Java Experiments/A/Hello World!.java
Normal file
@ -0,0 +1,7 @@
|
||||
public class Main
|
||||
{
|
||||
public static void main(String [] args)
|
||||
{
|
||||
System.out.print("Hello World!\n");
|
||||
}
|
||||
}
|
34
Java Experiments/A/格式化输出(常量练习).java
Normal file
34
Java Experiments/A/格式化输出(常量练习).java
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
Description
|
||||
用c语言的基本输出格式打印下列内容:
|
||||
100
|
||||
A
|
||||
3.140000
|
||||
|
||||
Input
|
||||
本题目没有输入数据
|
||||
|
||||
Output
|
||||
输出三行数据:
|
||||
100
|
||||
A
|
||||
3.140000
|
||||
|
||||
Sample
|
||||
Output
|
||||
100
|
||||
A
|
||||
3.140000
|
||||
*/
|
||||
public class Main
|
||||
{
|
||||
public static void main(String [] args)
|
||||
{
|
||||
int a=100;
|
||||
char c='A';
|
||||
double f=3.140000;
|
||||
System.out.printf("%d\n",a);
|
||||
System.out.printf("%c\n",c);
|
||||
System.out.printf("%f\n",f);
|
||||
}
|
||||
}
|
31
Java Experiments/A/洗衣服.java
Normal file
31
Java Experiments/A/洗衣服.java
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
Description
|
||||
X是一个勤劳的小孩,总是会帮助大人做家务。现在他想知道对于一根长为L的绳子能晾开多少件宽为W的衣服,显然这些衣服不能相互叠压。
|
||||
Input
|
||||
多组输入。
|
||||
每组输入两个整数L,W。
|
||||
Output
|
||||
输出答案。
|
||||
Sample
|
||||
Input
|
||||
10 5
|
||||
10 4
|
||||
Output
|
||||
2
|
||||
2
|
||||
*/
|
||||
import java.util.Scanner;
|
||||
public class Main
|
||||
{
|
||||
public static void main(String [] args)
|
||||
{
|
||||
Scanner in = new Scanner(System.in);
|
||||
int L,W;
|
||||
while(in.hasNextInt())
|
||||
{
|
||||
L=in.nextInt();
|
||||
W=in.nextInt();
|
||||
System.out.printf("%d\n",L/W);
|
||||
}
|
||||
}
|
||||
}
|
31
Java Experiments/A/火车.java
Normal file
31
Java Experiments/A/火车.java
Normal file
@ -0,0 +1,31 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Main
|
||||
{
|
||||
public static void main(String [] args)
|
||||
{
|
||||
int T,n,a,b;
|
||||
int max,temp;
|
||||
Scanner in =new Scanner(System.in);
|
||||
T=in.nextInt();
|
||||
|
||||
while(T!=0)
|
||||
{
|
||||
max=0;
|
||||
temp=0;
|
||||
n=in.nextInt();
|
||||
while(n!=0)
|
||||
{
|
||||
a=in.nextInt();
|
||||
b=in.nextInt();
|
||||
temp=temp-a+b;
|
||||
if(max<temp)
|
||||
max=temp;
|
||||
n--;
|
||||
}
|
||||
System.out.println(max);
|
||||
System.out.println();
|
||||
T--;
|
||||
}
|
||||
}
|
||||
}
|
34
Java Experiments/A/逆置正整数.java
Normal file
34
Java Experiments/A/逆置正整数.java
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
Description
|
||||
输入一个三位正整数,将它反向输出。
|
||||
|
||||
Input
|
||||
3位正整数。
|
||||
|
||||
Output
|
||||
逆置后的正整数。
|
||||
|
||||
Sample
|
||||
Input
|
||||
123
|
||||
Output
|
||||
321
|
||||
Hint
|
||||
注意130逆置后是31
|
||||
*/
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Main
|
||||
{
|
||||
public static void main(String [] args)
|
||||
{
|
||||
Scanner in = new Scanner(System.in);
|
||||
int n=in.nextInt();
|
||||
int a=n/100;
|
||||
int b=n/10-a*10;
|
||||
int c=n-a*100-b*10;
|
||||
int d=c*100+b*10+a;
|
||||
|
||||
System.out.printf("%d\n",d);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user