Skip to content

Commit d06c8eb

Browse files
committed
5.8.2
1 parent 0538cee commit d06c8eb

16 files changed

+342
-0
lines changed

.DS_Store

0 Bytes
Binary file not shown.

Java Experiments/.DS_Store

6 KB
Binary file not shown.

Java Experiments/A/.DS_Store

6 KB
Binary file not shown.

Java Experiments/A/A+B Problem.java

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import java.util.Scanner;
2+
3+
public class Main
4+
{
5+
public static void main(String [] args)
6+
{
7+
Scanner Data = new Scanner(System.in);
8+
int a,b;
9+
a=Data.nextInt();
10+
b= Data.nextInt();
11+
System.out.printf("%d",a+b);
12+
Data.close();
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import java.util.Scanner;
2+
3+
public class Main
4+
{
5+
public static void main(String [] args)
6+
{
7+
Scanner Data = new Scanner(System.in);
8+
int a,b;
9+
10+
while(Data.hasNextInt())
11+
{
12+
a=Data.nextInt();
13+
b=Data.nextInt();
14+
15+
System.out.printf("%d\n",a+b);
16+
}
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import java.util.Scanner;
2+
3+
public class Main
4+
{
5+
public static void main(String [] args)
6+
{
7+
Scanner Data = new Scanner(System.in);
8+
9+
int n,a,b;
10+
11+
n=Data.nextInt();
12+
while(n!=0)
13+
{
14+
a=Data.nextInt();
15+
b=Data.nextInt();
16+
17+
System.out.printf("%d\n",a+b);
18+
n--;
19+
}
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import java.util.*;
2+
3+
public class Main
4+
{
5+
public static void main(String [] args)
6+
{
7+
Scanner Data = new Scanner(System.in);
8+
9+
int n,a;
10+
int sum;
11+
while(true)
12+
{
13+
sum=0;
14+
n=Data.nextInt();
15+
if(n==0)
16+
break;
17+
18+
while(n!=0)
19+
{
20+
a=Data.nextInt();
21+
sum+=a;
22+
n--;
23+
}
24+
System.out.printf("%d\n",sum);
25+
}
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import java.util.*;
2+
3+
public class Main
4+
{
5+
public static void main(String [] args)
6+
{
7+
Scanner Data = new Scanner(System.in);
8+
9+
int n, a;
10+
int sum;
11+
12+
int N;
13+
14+
N=Data.nextInt();
15+
16+
while(N!=0)
17+
{
18+
sum=0;
19+
n=Data.nextInt();
20+
while(n!=0)
21+
{
22+
a=Data.nextInt();
23+
sum+=a;
24+
n--;
25+
}
26+
System.out.printf("%d\n",sum);
27+
N--;
28+
}
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import java.util.Scanner;
2+
3+
public class Main
4+
{
5+
public static void main(String [] args)
6+
{
7+
Scanner Data = new Scanner(System.in);
8+
9+
int n, a;
10+
int sum;
11+
12+
while(Data.hasNextInt())
13+
{
14+
sum=0;
15+
n=Data.nextInt();
16+
while(n!=0)
17+
{
18+
a=Data.nextInt();
19+
sum+=a;
20+
n--;
21+
}
22+
System.out.printf("%d\n",sum);
23+
}
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import java.util.Scanner;
2+
3+
public class Main
4+
{
5+
public static void main(String [] args)
6+
{
7+
Scanner Data = new Scanner(System.in);
8+
9+
int a,b;
10+
11+
while(Data.hasNextInt())
12+
{
13+
a=Data.nextInt();
14+
b=Data.nextInt();
15+
16+
System.out.printf("%d\n\n",a+b);
17+
}
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
Input
3+
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
4+
Output
5+
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.
6+
Sample
7+
Input
8+
3
9+
4 1 2 3 4
10+
5 1 2 3 4 5
11+
3 1 2 3
12+
Output
13+
10
14+
15+
15
16+
17+
6
18+
*/
19+
20+
import java.util.Scanner;
21+
22+
public class Main
23+
{
24+
public static void main(String[] args)
25+
{
26+
Scanner in = new Scanner(System.in);
27+
28+
int N;
29+
N = in.nextInt();
30+
31+
int M;
32+
int sum;
33+
int t;
34+
35+
while(N>0)
36+
{
37+
sum=0;
38+
M=in.nextInt();
39+
while(M>0)
40+
{
41+
t=in.nextInt();
42+
sum+=t;
43+
M--;
44+
}
45+
System.out.printf("%d\n\n",sum);
46+
N--;
47+
}
48+
49+
50+
}
51+
}

Java Experiments/A/Hello World!.java

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
public class Main
2+
{
3+
public static void main(String [] args)
4+
{
5+
System.out.print("Hello World!\n");
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
Description
3+
用c语言的基本输出格式打印下列内容:
4+
100
5+
A
6+
3.140000
7+
8+
Input
9+
本题目没有输入数据
10+
11+
Output
12+
输出三行数据:
13+
100
14+
A
15+
3.140000
16+
17+
Sample
18+
Output
19+
100
20+
A
21+
3.140000
22+
*/
23+
public class Main
24+
{
25+
public static void main(String [] args)
26+
{
27+
int a=100;
28+
char c='A';
29+
double f=3.140000;
30+
System.out.printf("%d\n",a);
31+
System.out.printf("%c\n",c);
32+
System.out.printf("%f\n",f);
33+
}
34+
}

Java Experiments/A/洗衣服.java

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
Description
3+
X是一个勤劳的小孩,总是会帮助大人做家务。现在他想知道对于一根长为L的绳子能晾开多少件宽为W的衣服,显然这些衣服不能相互叠压。
4+
Input
5+
多组输入。
6+
每组输入两个整数L,W。
7+
Output
8+
输出答案。
9+
Sample
10+
Input
11+
10 5
12+
10 4
13+
Output
14+
2
15+
2
16+
*/
17+
import java.util.Scanner;
18+
public class Main
19+
{
20+
public static void main(String [] args)
21+
{
22+
Scanner in = new Scanner(System.in);
23+
int L,W;
24+
while(in.hasNextInt())
25+
{
26+
L=in.nextInt();
27+
W=in.nextInt();
28+
System.out.printf("%d\n",L/W);
29+
}
30+
}
31+
}

Java Experiments/A/火车.java

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import java.util.Scanner;
2+
3+
public class Main
4+
{
5+
public static void main(String [] args)
6+
{
7+
int T,n,a,b;
8+
int max,temp;
9+
Scanner in =new Scanner(System.in);
10+
T=in.nextInt();
11+
12+
while(T!=0)
13+
{
14+
max=0;
15+
temp=0;
16+
n=in.nextInt();
17+
while(n!=0)
18+
{
19+
a=in.nextInt();
20+
b=in.nextInt();
21+
temp=temp-a+b;
22+
if(max<temp)
23+
max=temp;
24+
n--;
25+
}
26+
System.out.println(max);
27+
System.out.println();
28+
T--;
29+
}
30+
}
31+
}
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
Description
3+
输入一个三位正整数,将它反向输出。
4+
5+
Input
6+
3位正整数。
7+
8+
Output
9+
逆置后的正整数。
10+
11+
Sample
12+
Input
13+
123
14+
Output
15+
321
16+
Hint
17+
注意130逆置后是31
18+
*/
19+
import java.util.Scanner;
20+
21+
public class Main
22+
{
23+
public static void main(String [] args)
24+
{
25+
Scanner in = new Scanner(System.in);
26+
int n=in.nextInt();
27+
int a=n/100;
28+
int b=n/10-a*10;
29+
int c=n-a*100-b*10;
30+
int d=c*100+b*10+a;
31+
32+
System.out.printf("%d\n",d);
33+
}
34+
}

0 commit comments

Comments
 (0)