Re: [問題]新手問題

看板Perl作者 (小a)時間15年前 (2008/09/19 01:19), 編輯推噓1(101)
留言2則, 1人參與, 最新討論串2/4 (看更多)
※ 引述《yingwan (yingwan)》之銘言: : 大家好 : 剛接觸perl第二個禮拜,老師出的一個問題我一直卡著,所以上來請教各位前輩 : 我們老師要我們寫出一個指令,先問喜歡的顏色,再依照對方回答排出以下圖案 : red red red red red red red red red red : red red : red red : red red red red red red red red red red : 問題就在,我用red測試OK,但是如果用blue 就會變成 : blue blue blue blue blue blue blue blue blue blue : blue blue : blue blue : blue blue blue blue blue blue blue blue blue blue : 可是我希望是 : blue blue blue blue blue blue blue blue blue blue : blue blue : blue blue : blue blue blue blue blue blue blue blue blue blue : 我把我的步驟貼在下面,希望有前輩可以指點我一下,謝謝 #!usr/bin/perl -w print "What is your favorite color?\n "; $a=<STDIN>; chomp $a; #$b= ($a ." " . $a. " ") x 5 ; $b = $a . " $a" x 9; #$c= $a . "\t" x 5 . $a; $c = $a . " " x (length(" $a") * 9) . " $a"; print "$b\n"; print "$c\n"; print "$c\n"; print "$b\n"; -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.232.236.185

09/19 21:35, , 1F
感謝大大,我昨天解出來了,我用\t加" "
09/19 21:35, 1F

09/19 21:37, , 2F
再乘以$a長度
09/19 21:37, 2F
文章代碼(AID): #18qeskL8 (Perl)
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 4 篇):
文章代碼(AID): #18qeskL8 (Perl)