Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita3e0cf8

Browse files
committed
fix bugs in MinimizingLateness(TheAlgorithms#765)
1 parent1ebe496 commita3e0cf8

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

‎MinimizingLateness/MinimizingLateness.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
packageMinimizingLateness;
22

3-
importjava.io.*;
4-
importjava.util.*;
3+
4+
importjava.io.BufferedReader;
5+
importjava.io.FileReader;
6+
importjava.io.IOException;
7+
importjava.util.StringTokenizer;
58

69
publicclassMinimizingLateness {
710

@@ -18,23 +21,23 @@ public Schedule(int t, int d) {
1821
}
1922

2023
publicstaticvoidmain(String[]args)throwsIOException {
21-
// TODO Auto-generated method stub
2224
StringTokenizertoken;
2325

24-
Stringch;
25-
BufferedReaderin =newBufferedReader(newFileReader("input.txt"));
26-
intindexCount;// size of array index
27-
ch =in.readLine();
28-
indexCount =Integer.parseInt(ch);// The first line specifies the size of the operation (= the size of the array)
26+
BufferedReaderin =newBufferedReader(newFileReader("MinimizingLateness/lateness_data.txt"));
27+
Stringch =in.readLine();
28+
if (ch ==null ||ch.isEmpty()) {
29+
return;
30+
}
31+
intindexCount =Integer.parseInt(ch);
2932
System.out.println("Input Data : ");
3033
System.out.println(indexCount);// number of operations
31-
Schedulearray[] =newSchedule[indexCount];// Create an array to hold the operation
34+
Schedule[]array =newSchedule[indexCount];// Create an array to hold the operation
3235
inti =0;
3336
while ((ch =in.readLine()) !=null) {
3437
token =newStringTokenizer(ch," ");
3538
// Include the time required for the operation to be performed in the array and the time it should be completed.
3639
array[i] =newSchedule(Integer.parseInt(token.nextToken()),Integer.parseInt(token.nextToken()));
37-
i++;// 다음 인덱스
40+
i++;
3841
System.out.println(array[i -1].t +" " +array[i -1].d);
3942
}
4043

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp