Blog.okuryu
最初に出した課題は掛け算の九九表を出力せよ、です。81回printする不届き者もいますので10行で、が条件。結構難しい。PHPの場合、HTMLのtableで出力するのが簡単なので「24」の項を太字にする、を次の課題にすると必要な構文はだいたい使うことになります。今まで何人かに九九表を書いてもらいましたがそれなりにいい課題なのでは、と思ってます。
ちょっと自分でも書いてみた。
<?php
echo '<table>';
for( $i = 1; $i <= 9; $i++ ) {
echo '<tr>';
for( $j = 1; $j <= 9; $j++ ) echo $i * $j == 24 ? '<td><strong>' . $i * $j . '</strong></td>' : '<td>' . $i * $j . '</td>';
echo '</tr>';
}
echo '</table>';
?>とりあえず10行にはおさまった。他にも書き方あるんだろうか。
このエントリーのトラックバックURL:
http://www.okuryu.com/mt/mt-tb.cgi/193
bogdanlebu | 2008-04-07T04:14:14+09:00
I think that you really can judge people by the way they comment different stuff. Some people, even expressing negative thoughts, are still polite and they respect and understand other people. Some people are not even trying to be nice, they just don’t care. I think self-confident person will always act nice, no matter what other people do
sandeep | 2008-04-09T18:56:08+09:00
Do you fairly think this is news? I like and read your blog to get necessary information, but sometimes melancholy kills me