<![CDATA[Latest posts for the topic "Command line Quizzes"]]> /hvaonline/posts/list/24.html JForum - http://www.jforum.net Command line Quizzes Ruby is a pink to blood red gemstone, a variety of the mineral corundum (aluminium oxide). The common red color is caused mainly by the element chromium. Its name comes from ruber, Latin for red. Other varieties of gem-quality corundum are called sapphires. It is considered one of the four precious stones, together with the sapphire, the emerald and the diamond. Improvements used include color alteration, improving transparency by dissolving rutile inclusions, healing of fractures (cracks) or even completely filling them. Prices of rubies are primarily determined by color (the brightest and best "red" called Pigeon Blood Red, command a huge premium over other rubies of similar quality). After color follows clarity: similar to diamonds, a clear stone will command a premium, but a ruby without any needle-like rutile inclusions will indicate the stone has been treated one way or another. Cut and carat (size) will also determine the price. Rubies have a hardness of 9.0 on the Mohs scale of mineral hardness. Among the natural gems only diamond is harder, with a Mohs 10.0 by definition.   Câu 2 : Script in 1 ma trận 10x10 với các số nguyên ngẫu nhiên từ 0 đến 9 ra màn hình ? Chúc vui !]]> /hvaonline/posts/list/20819.html#123599 /hvaonline/posts/list/20819.html#123599 GMT Re: Command line Quizzes /hvaonline/posts/list/20819.html#123635 /hvaonline/posts/list/20819.html#123635 GMT Re: Command line Quizzes /hvaonline/posts/list/20819.html#123655 /hvaonline/posts/list/20819.html#123655 GMT Re: Command line Quizzes

kholostoi wrote:
bài 2: theo mình nên dùng 3 ý cơ bản như sau: 1. $RANDOM: mỗi lần sẽ in 1 số ngẫu nhiên từ 0-32767: vd: number=$RANDOM 2. dùng command let: let "number %= 10" --> sinh ngẫu nhiên từ 0-9 3. dùng 2 vòng lặp for hoặc while để in thành ma trận. 
Hehe triển khai theo ý của anh nè (vì mới là newbie nên viết theo gợi ý trước :^) ) Code:
#!/bin/bash
for ((x=0; x<10; x++)) 
	do 
		y=0
		until [ "$y" = "9" ]
			do
				number=$RANDOM
				let "number %=10"
				echo -n "$number "
				y=$((y + 1))
			done
		number=$RANDOM
		let "number %=10"
		echo $number
	done
exit 0
Đoạn: Code:
number=$RANDOM
		let "number %=10"
		echo $number
là do em muốn ma trận khi in ra nhìn đẹp đẹp. Nếu không thì có thể sửa lại: Code:
#!/bin/bash
for ((x=0; x<10; x++)) 
	do 
		for ((y=0; y<10; y++)) 
			do
				number=$RANDOM
				let "number %=10"
				echo -n "$number "
			done
		echo ""
	done
exit 0
Mí anh coi giùm em vậy là ổn chưa? ;-) ]]>
/hvaonline/posts/list/20819.html#124309 /hvaonline/posts/list/20819.html#124309 GMT
Re: Command line Quizzes Code:
for ((i=1; i<11; i++)); do
   Hien=""
   for ((j=1; j<11; j++)); do
      Hien="${Hien} ${RANDOM:1:1}"
   done
   echo $Hien
done
]]>
/hvaonline/posts/list/20819.html#124320 /hvaonline/posts/list/20819.html#124320 GMT
Re: Command line Quizzes Code:
for i in `seq 1 10`; do
  for i in `seq 1 10`; do expr $RANDOM % 10; done | xargs
done
Còn câu 1, ai có thể viết trong ... 1 dòng được không ? Note: Từ có 4 ký tự "phổ biến nhất" nghĩa là xuất hiện nhiều nhất .]]>
/hvaonline/posts/list/20819.html#124659 /hvaonline/posts/list/20819.html#124659 GMT