#16857: Re:為什麼這樣不行?能幫我看一下~


sa930670 (ss93067)

學校 : 不指定學校
編號 : 91633
來源 : [36.237.80.3]
最後登入時間 :
2019-02-14 13:08:12
c833. 第四題:二維陣列 -- 2018資訊學科能力競賽高中組高雄市 | From: [36.237.80.3] | 發表日期 : 2019-02-14 13:17

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;


public class aa {

public static void main(String[] args) throws IOException{

FileReader fr = new FileReader("LBS.csv");
BufferedReader br = new BufferedReader(fr);
String str = null;
String Data[][];
ArrayList name = new ArrayList();
ArrayList number = new ArrayList();
ArrayList longitude = new ArrayList();
ArrayList latitude = new ArrayList();


//int num = 0;
while((str = br.readLine())!= null){
String tempArray[] = str.split("\\,");
name.add(tempArray[0]);
number.add(tempArray[1]);
longitude.add(tempArray[2]);
latitude.add(tempArray[3]);

}

Data = new String [name.size()][4];


for(int i = 0; i< name.size(); i++){
Data[i][0] = (String) name.get(i);
Data[i][1] = (String) number.get(i);
Data[i][2] = (String) longitude.get(i);
Data[i][3] = (String) latitude.get(i);

}
for(int i = 0; i < Data.length; i++) {
for(int j = 0; j < Data[0].length; j++) {
for(int x = 0; x <= 300; x++) {
for(int q = 0; q <= 300; q++) {
//System.out.printf("x="+x+"q="+q+"\n");
System.out.println(x+" "+Data[x][1]+" "+q+" "+Data[q][1]);
}
}

}
}
}
}
執行程式,結果是
0 1_1 0 1_1
~
0 1_1 299 10_30

但是我想要的結果是
0 1_1 0 1_1
~
0 1_1 299 10_30

~

299 10_30 0 1_1
~
299 10_30 299 10_30
要怎麼修改?

 

LBS.csv 內容如下:
菩提樹,1_1,120.253528,22.997781
菩提樹,1_2,120.253601,22.997176
菩提樹,1_3,120.253602,22.997125
菩提樹,1_4,120.253596,22.997084
菩提樹,1_5,120.253598,22.997026
菩提樹,1_6,120.253578,22.996967
菩提樹,1_7,120.253609,22.996907
菩提樹,1_8,120.253581,22.996885
菩提樹,1_9,120.253509,22.996789
菩提樹,1_10,120.253665,22.996524
菩提樹,1_11,120.253551,22.996519
菩提樹,1_12,120.253552,22.996437
菩提樹,1_13,120.253546,22.996404
菩提樹,1_14,120.253540,22.996367
菩提樹,1_15,120.253549,22.996362
菩提樹,1_16,120.253572,22.996335
菩提樹,1_17,120.253581,22.996355
菩提樹,1_18,120.253592,22.996313
菩提樹,1_19,120.253580,22.996284
菩提樹,1_20,120.253558,22.996256
菩提樹,1_21,120.253532,22.996220
菩提樹,1_22,120.253576,22.996197
菩提樹,1_23,120.253546,22.996181
菩提樹,1_24,120.253630,22.996036
菩提樹,1_25,120.253432,22.996004
菩提樹,1_26,120.253592,22.995924
菩提樹,1_27,120.253613,22.995900
菩提樹,1_28,120.253598,22.995887
菩提樹,1_29,120.253576,22.995821
菩提樹,1_30,120.253552,22.995803
大葉欖樹,2_1,120.251662,22.995144
大葉欖樹,2_2,120.251721,22.995144
大葉欖樹,2_3,120.251716,22.995116
大葉欖樹,2_4,120.251713,22.995096
大葉欖樹,2_5,120.251718,22.995095
大葉欖樹,2_6,120.251714,22.995088
大葉欖樹,2_7,120.251714,22.995078
大葉欖樹,2_8,120.251715,22.995066
大葉欖樹,2_9,120.251719,22.994939
大葉欖樹,2_10,120.251687,22.994904
大葉欖樹,2_11,120.251554,22.994917
大葉欖樹,2_12,120.251570,22.994844
大葉欖樹,2_13,120.251866,22.994563
大葉欖樹,2_14,120.252587,22.994208
大葉欖樹,2_15,120.251546,22.994605
大葉欖樹,2_16,120.251447,22.994602
大葉欖樹,2_17,120.251281,22.994687
大葉欖樹,2_18,120.251249,22.994662
大葉欖樹,2_19,120.251150,22.994587
大葉欖樹,2_20,120.250990,22.994763
大葉欖樹,2_21,120.251019,22.994754
大葉欖樹,2_22,120.250992,22.994758
大葉欖樹,2_23,120.250946,22.994769
大葉欖樹,2_24,120.250945,22.994770
大葉欖樹,2_25,120.250785,22.994835
大葉欖樹,2_26,120.250784,22.994916
大葉欖樹,2_27,120.250737,22.994669
大葉欖樹,2_28,120.251634,22.994884
大葉欖樹,2_29,120.251642,22.994905
大葉欖樹,2_30,120.251447,22.994602
小葉欖仁,3_1,120.251020,22.996323
小葉欖仁,3_2,120.251001,22.996308
小葉欖仁,3_3,120.250965,22.996313
小葉欖仁,3_4,120.250975,22.996236
小葉欖仁,3_5,120.250952,22.996229
小葉欖仁,3_6,120.250785,22.996274
小葉欖仁,3_7,120.250769,22.996245
小葉欖仁,3_8,120.250765,22.996251
小葉欖仁,3_9,120.250732,22.996264
小葉欖仁,3_10,120.250644,22.996238
小葉欖仁,3_11,120.250692,22.996258
小葉欖仁,3_12,120.250567,22.996306
小葉欖仁,3_13,120.250680,22.996239
小葉欖仁,3_14,120.250720,22.996200
小葉欖仁,3_15,120.250713,22.996189
小葉欖仁,3_16,120.250713,22.996179
小葉欖仁,3_17,120.250668,22.996152
小葉欖仁,3_18,120.250670,22.996082
小葉欖仁,3_19,120.250715,22.996108
小葉欖仁,3_20,120.250631,22.995922
小葉欖仁,3_21,120.250686,22.995982
小葉欖仁,3_22,120.250688,22.995966
小葉欖仁,3_23,120.250684,22.995972
小葉欖仁,3_24,120.250719,22.995943
小葉欖仁,3_25,120.250644,22.995969
小葉欖仁,3_26,120.250615,22.995219
小葉欖仁,3_27,120.250680,22.995186
小葉欖仁,3_28,120.250662,22.995098
小葉欖仁,3_29,120.250678,22.995073
小葉欖仁,3_30,120.250653,22.995022
大王椰子,4_1,120.252032,22.995456
大王椰子,4_2,120.251857,22.995426
大王椰子,4_3,120.251825,22.995468
大王椰子,4_4,120.251814,22.995466
大王椰子,4_5,120.251577,22.995438
大王椰子,4_6,120.251916,22.994701
大王椰子,4_7,120.251921,22.994704
大王椰子,4_8,120.251522,22.994556
大王椰子,4_9,120.251441,22.994619
大王椰子,4_10,120.251862,22.994623
大王椰子,4_11,120.251375,22.994334
大王椰子,4_12,120.252086,22.994300
大王椰子,4_13,120.252120,22.994235
大王椰子,4_14,120.252123,22.994234
大王椰子,4_15,120.252152,22.994176
大王椰子,4_16,120.252493,22.994186
大王椰子,4_17,120.252412,22.994379
大王椰子,4_18,120.252401,22.994369
大王椰子,4_19,120.252403,22.994363
大王椰子,4_20,120.252172,22.994236
大王椰子,4_21,120.252162,22.994116
大王椰子,4_22,120.252109,22.994115
大王椰子,4_23,120.252128,22.994091
大王椰子,4_24,120.252201,22.994151
大王椰子,4_25,120.252203,22.994163
大王椰子,4_26,120.252202,22.994165
大王椰子,4_27,120.252218,22.994273
大王椰子,4_28,120.252222,22.994270
大王椰子,4_29,120.252213,22.994227
大王椰子,4_30,120.252170,22.994252
榕樹,5_1,120.251893,22.996189
榕樹,5_2,120.251816,22.996190
榕樹,5_3,120.251717,22.996201
榕樹,5_4,120.251705,22.996208
榕樹,5_5,120.251726,22.996181
榕樹,5_6,120.251808,22.996045
榕樹,5_7,120.251816,22.996604
榕樹,5_8,120.251623,22.995998
榕樹,5_9,120.251699,22.995915
榕樹,5_10,120.251699,22.995914
榕樹,5_11,120.251713,22.995765
榕樹,5_12,120.251744,22.995730
榕樹,5_13,120.251742,22.995697
榕樹,5_14,120.251744,22.995529
榕樹,5_15,120.251692,22.995423
榕樹,5_16,120.251708,22.995376
榕樹,5_17,120.251735,22.995357
榕樹,5_18,120.251715,22.995294
榕樹,5_19,120.251744,22.995271
榕樹,5_20,120.251748,22.995236
榕樹,5_21,120.251743,22.995151
榕樹,5_22,120.251816,22.994977
榕樹,5_23,120.251818,22.994974
榕樹,5_24,120.252382,22.995183
榕樹,5_25,120.252389,22.995148
榕樹,5_26,120.252499,22.994943
榕樹,5_27,120.252200,22.994958
榕樹,5_28,120.252151,22.994976
榕樹,5_29,120.251978,22.995012
榕樹,5_30,120.251984,22.994940
木棉樹,6_1,120.253702,22.998181
木棉樹,6_2,120.253705,22.998113
木棉樹,6_3,120.253731,22.998119
木棉樹,6_4,120.253124,22.998085
木棉樹,6_5,120.253710,22.998079
木棉樹,6_6,120.253689,22.998030
木棉樹,6_7,120.253696,22.997961
木棉樹,6_8,120.253715,22.997911
木棉樹,6_9,120.253710,22.997904
木棉樹,6_10,120.253689,22.997841
木棉樹,6_11,120.253675,22.997828
木棉樹,6_12,120.253660,22.997796
木棉樹,6_13,120.253619,22.997764
木棉樹,6_14,120.253687,22.997765
木棉樹,6_15,120.253641,22.997756
木棉樹,6_16,120.253695,22.997658
木棉樹,6_17,120.253667,22.997705
木棉樹,6_18,120.253671,22.997701
木棉樹,6_19,120.253662,22.997814
木棉樹,6_20,120.253652,22.997817
木棉樹,6_21,120.253655,22.997827
木棉樹,6_22,120.253657,22.997839
木棉樹,6_23,120.253662,22.998012
木棉樹,6_24,120.253676,22.998041
木棉樹,6_25,120.253680,22.998061
木棉樹,6_26,120.253685,22.998065
木棉樹,6_27,120.253702,22.998129
木棉樹,6_28,120.253676,22.998065
木棉樹,6_29,120.253682,22.998115
木棉樹,6_30,120.253681,22.998126
蒲葵,7_1,120.252477,22.995784
蒲葵,7_2,120.252040,22.995772
蒲葵,7_3,120.252396,22.995601
蒲葵,7_4,120.252361,22.995706
蒲葵,7_5,120.252335,22.995612
蒲葵,7_6,120.252127,22.995715
蒲葵,7_7,120.252113,22.995780
蒲葵,7_8,120.252042,22.995810
蒲葵,7_9,120.251986,22.995848
蒲葵,7_10,120.251912,22.995793
蒲葵,7_11,120.251993,22.995836
蒲葵,7_12,120.251991,22.995369
蒲葵,7_13,120.251953,22.995660
蒲葵,7_14,120.251889,22.995738
蒲葵,7_15,120.251825,22.995792
蒲葵,7_16,120.251791,22.995810
蒲葵,7_17,120.251804,22.995812
蒲葵,7_18,120.251923,22.995512
蒲葵,7_19,120.251835,22.995836
蒲葵,7_20,120.251926,22.995912
蒲葵,7_21,120.252083,22.995983
蒲葵,7_22,120.252122,22.995798
蒲葵,7_23,120.252019,22.995721
蒲葵,7_24,120.252213,22.995628
蒲葵,7_25,120.252369,22.995631
蒲葵,7_26,120.252381,22.995696
蒲葵,7_27,120.252396,22.995724
蒲葵,7_28,120.252417,22.995816
蒲葵,7_29,120.252428,22.995824
蒲葵,7_30,120.252459,22.995712
白千層,8_1,120.252586,22.995977
白千層,8_2,120.252761,22.995895
白千層,8_3,120.252823,22.995874
白千層,8_4,120.252845,22.995899
白千層,8_5,120.253069,22.995941
白千層,8_6,120.253157,22.995805
白千層,8_7,120.253164,22.995787
白千層,8_8,120.253225,22.995838
白千層,8_9,120.253473,22.995842
白千層,8_10,120.253724,22.995922
白千層,8_11,120.253681,22.995873
白千層,8_12,120.253437,22.997375
白千層,8_13,120.253448,22.997526
白千層,8_14,120.253452,22.997455
白千層,8_15,120.253501,22.997441
白千層,8_16,120.253373,22.997489
白千層,8_17,120.253345,22.997471
白千層,8_18,120.252227,22.994279
白千層,8_19,120.252255,22.994274
白千層,8_20,120.252251,22.994270
白千層,8_21,120.252246,22.994263
白千層,8_22,120.252241,22.994259
白千層,8_23,120.252235,22.994251
白千層,8_24,120.252229,22.994246
白千層,8_25,120.252152,22.993943
白千層,8_26,120.252179,22.994199
白千層,8_27,120.252164,22.994154
白千層,8_28,120.252158,22.994139
白千層,8_29,120.253608,22.997263
白千層,8_30,120.253619,22.997248
龍柏,9_1,120.252494,22.996569
龍柏,9_2,120.252498,22.996528
龍柏,9_3,120.252499,22.996528
龍柏,9_4,120.252514,22.996536
龍柏,9_5,120.252109,22.996538
龍柏,9_6,120.252483,22.996568
龍柏,9_7,120.252494,22.996584
龍柏,9_8,120.252495,22.996583
龍柏,9_9,120.252473,22.996558
龍柏,9_10,120.252472,22.996555
龍柏,9_11,120.252466,22.996570
龍柏,9_12,120.252409,22.993547
龍柏,9_13,120.252468,22.996561
龍柏,9_14,120.252470,22.996559
龍柏,9_15,120.252462,22.996566
龍柏,9_16,120.252954,22.996551
龍柏,9_17,120.252505,22.996548
龍柏,9_18,120.252474,22.996546
龍柏,9_19,120.252449,22.996559
龍柏,9_20,120.252446,22.996555
龍柏,9_21,120.252443,22.996550
龍柏,9_22,120.252400,22.996525
龍柏,9_23,120.252389,22.996527
龍柏,9_24,120.252423,22.996539
龍柏,9_25,120.252422,22.996561
龍柏,9_26,120.252426,22.996571
龍柏,9_27,120.252430,22.996578
龍柏,9_28,120.252433,22.996581
龍柏,9_29,120.252436,22.996582
龍柏,9_30,120.252436,22.996582
黃連木,10_1,120.251708,22.996111
黃連木,10_2,120.251803,22.996086
黃連木,10_3,120.251768,22.996097
黃連木,10_4,120.251046,22.996252
黃連木,10_5,120.250991,22.996336
黃連木,10_6,120.250980,22.996404
黃連木,10_7,120.251083,22.996290
黃連木,10_8,120.251532,22.996107
黃連木,10_9,120.251631,22.996045
黃連木,10_10,120.251084,22.996265
黃連木,10_11,120.250809,22.996336
黃連木,10_12,120.251088,22.996243
黃連木,10_13,120.250912,22.996196
黃連木,10_14,120.251716,22.996201
黃連木,10_15,120.251760,22.996204
黃連木,10_16,120.251752,22.996182
黃連木,10_17,120.251672,22.996062
黃連木,10_18,120.251630,22.996107
黃連木,10_19,120.251349,22.996187
黃連木,10_20,120.251049,22.996238
黃連木,10_21,120.250988,22.996259
黃連木,10_22,120.250980,22.996269
黃連木,10_23,120.250973,22.996273
黃連木,10_24,120.251008,22.996204
黃連木,10_25,120.251410,22.996116
黃連木,10_26,120.251156,22.996293
黃連木,10_27,120.251140,22.996281
黃連木,10_28,120.251161,22.996203
黃連木,10_29,120.250911,22.996376
黃連木,10_30,120.251139,22.996089

 
ZeroJudge Forum