看板 [ Perl ]
討論串[問題] 如何從檔案裡取數字並相加
共 3 篇文章
首頁
上一頁
1
下一頁
尾頁

推噓1(1推 0噓 0→)留言1則,0人參與, 最新作者saka12 (saka)時間13年前 (2012/02/10 12:47), 編輯資訊
0
0
1
內容預覽:
讀檔案那段跳過. for my $new(@data). {. my @num = $new =~ /\d+/g;. for my $out(@num) {. if (!$saw{$out}) {. print "$out ";. $saw{$out} = 1;. $partialSum .= "$
(還有136個字)

推噓2(2推 0噓 0→)留言2則,0人參與, 最新作者dryman (dryman)時間13年前 (2012/02/09 10:32), 編輯資訊
0
0
0
內容預覽:
非常直白的寫法. $string="your stirng";. @nums = ($string =~ /\d+/g);. %unique = map { $_, 1} @nums;. $sum += $_ for keys %unique;. print $sum;. --. 發信站: 批踢

推噓0(0推 0噓 0→)留言0則,0人參與, 最新作者saka12 (saka)時間13年前 (2012/02/09 09:55), 編輯資訊
0
0
0
內容預覽:
大家好:. 我手邊有一個檔案 input.txt 如下. the 77 survey: 77 out of 100 people will not pick the number 1 as the first choice.A stitch in time saves 9 but only if y
(還有111個字)
首頁
上一頁
1
下一頁
尾頁