今日の曜日を表示するスクリプト(dayofweek)を作成せよ。dateのマニュアルをよく見る。 % sh dayofweek Monday %
パラメータとして2つの整数を入力して、2数の最小公倍数を計算するスクリプト(lcm)を作成せよ。ただし、2数をx,yとしたとき、x・ y=gcd・lcmである。 % sh lcm 10 12 lcm of 10 and 12 is 60 %
課題3
パラメータとして複数のファイル名を受け取り、それぞれのファイルの行数を表示するスクリプト(listlines)を作成せよ。 % sh listlines a b c file a has 5 lines. file b has 9 lines. file c has 12 lines. %
課題4
パラメータとして2つのファイル名を受け取り、それぞれのファイルに共通する単語の数を表示するスクリプト(samewords)を作成せ よ。2つのファイルにそれぞれ含まれる単語の数と、2つのファイルをひとつにしたファイルに含まれる単語の数がわかれば... % sh samewords a b file a and b have 6 same words. % できた人は天才!!!!
このPSPは、新規格UMD(ユニバーサルメディアディスク)というディスクを利用しており、そのサイズは直径6cmととても小さい(CDの半分程度)。 容量は1.8GBとなっている。 画面は4.5インチのTFT液晶で、480px x 272px(16:9)。MPEG4の再生やポリゴンも表示可能。外部端子として、USB2.0とメモリースティックコネクタが用意されているという。
#今日の曜日を表示するスクリプト(dayofweek)を作成せよ。dateのマニュアルを~よく見る。 #% sh dayofweek #Monday #% % LC_ALL=C date +%A Sunday 0091名無しさん@お腹いっぱい。2007/11/04(日) 11:34:12 #パラメータとして2つの整数を入力して、2数の最小公倍数を計算するスクリプト(lcm)を作成せよ。ただし、2数をx,yとしたとき、x・ #y=gcd・lcmである。 #% sh lcm 10 12 #lcm of 10 and 12 is 60 #%
if [ $1 -gt $2 ]; then a=$1 b=$2 elif [ $1 -lt $2 ]; then a=$2 b=$1 else echo lcm of $1 and $2 is $1 exit fi
m() { expr $1 \* $2 } 0092名無しさん@お腹いっぱい。2007/11/04(日) 11:34:59 a_value=$a a_int=1 b_int=1 while [ 1 ] do b_value=`m $b $b_int` if [ $b_value -gt $a_value ]; then a_int=`expr $a_int + 1` a_value=`m $a $a_int` elif [ $b_value -eq $a_value ]; then echo lcm of $1 and $2 is $b_value exit fi b_int=`expr $b_int + 1` done 0093名無しさん@お腹いっぱい。2007/11/04(日) 11:35:41 #課題3
#パラメータとして複数のファイル名を受け取り、それぞれのファイルの行数を表示するスクリプト(listlines)を作成せよ。 #% sh listlines a b c #file a has 5 lines. #file b has 9 lines. #file c has 12 lines. #%
for x in $* do echo file $x has `wc -l $x` lines. done 0094名無しさん@お腹いっぱい。2007/11/04(日) 11:38:09 #課題4
#パラメータとして2つのファイル名を受け取り、それぞれのファイルに共通する単語の数を表示するスクリプト(samewords)を作成せ #よ。2つのファイルにそれぞれ含まれる単語の数と、2つのファイルをひとつにしたファイルに含まれる単語の数がわかれば... #% sh samewords a b #file a and b have 6 same words. #% #できた人は天才!!!! 0095名無しさん@お腹いっぱい。2007/11/04(日) 11:39:11 a=$1 b=$2 count=0
for line in `cat $a`; do if [ -n "$line" ];then set $line for var in $*;do grep -w $var > /dev/null <<-! $seen ! if [ $? -eq 0 ];then continue fi
grep -w "$var" "$b" > /dev/null if [ $? -eq 0 ]; then count=`expr $count + 1` fi seen="$seen $var" done fi done echo file $a and $b have $count same words. 0096名無しさん@お腹いっぱい。2010/03/24(水) 18:39:44 10年後の俺へ 元気でやってるか?SEになれてる?彼女できた?