Created
January 21, 2010 10:24
-
-
Save dwiash/282711 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PETUNJUK: | |
data inputan terletak pada file input.txt | |
data inputan harus menggunakan format yang telah ditentukan. | |
formatnya adalah seperti berikut: | |
6 | |
4 | |
1 2 3 2 3 4 | |
3 4 5 5 6 7 | |
0 12 3 4 5 6 | |
1 2 3 12 31 2 | |
baris pertama meruapakan jumlah kolom matrix (pada contoh=6 kolom) | |
baris kedua merupakan jumlah baris matrix (pada contoh=4 baris) | |
baris selanjutnya merupakan matrix inputan | |
PERHATIAN, file input.txt harus berada pada folder yang sama dengan program yg telah dicompile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 | |
4 | |
1 2 3 2 3 4 | |
3 4 5 5 6 7 | |
0 12 3 4 5 6 | |
1 2 3 12 31 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedReader; | |
import java.io.File; | |
import java.io.FileReader; | |
import java.io.IOException; | |
public class Main { | |
public static void main(String[] args) { | |
try { | |
File fileInput = new File("input.txt"); | |
BufferedReader buffRead = null; | |
buffRead = new BufferedReader(new FileReader(fileInput)); | |
int jumlahKolom = Integer.parseInt(buffRead.readLine()); | |
int jumlahBaris = Integer.parseInt(buffRead.readLine()); | |
String[] s = new String[jumlahKolom]; | |
int i,j,k,l = 0; | |
String str = " "; | |
for(i=0; i<jumlahBaris; i++){ | |
str = buffRead.readLine(); | |
s = str.split(" "); | |
l = s.length; | |
for (j=0; j<l; j++){ | |
k = l - j - 1; | |
System.out.print(s[k] + " "); | |
} | |
System.out.println(""); | |
} | |
} catch (Exception ex) { | |
// | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment