2014.1.16

1.思维导图:

2.

#!/bin/bash 
read -p "please enter file:" file
if [ -e ./$file ]
then
	if [ -d $file ]
	then
		echo 是目录文件
	elif [ -f $file ]
	then
		if [ -w $file -a -r $file -a -x $file ]
		then
			echo hello >> $file
			echo `cat $file`
		else
			chmod 777 $file
			echo hello >> $file
			echo `cat $file`
		fi
	fi
	else
	echo error
fi
			if [ -L ./$file ]
		    then
			echo `ls -lh $file`
		fi

3.

#!/bin/bash 
read -p "please enter an number:" a
for((i=1;i<=${#a};i++))
do
	b=$b${a:0-$i:1}
done
echo $b
if [ $b -eq $a ]
then
	echo yes
else
	echo no
fi

 

4.

#!/bin/bash 
read -p "please enter n:" n
if [ $n -eq 0 ]
then
	echo 1
else
	a=1
	for((i=1;i<=n;i++))
	do
		((a*=i))
	done
	echo $a
fi

 

5.

 

#!/bin/bash 
for((i=1;i<=4;i++))
do
	for((j=0;j<=4-i;j++))
	do
		echo -n " "  
	done
	for((k=0;k<2*i-1;k++))
	do
		echo -n "*"
	done
	echo ""
done

6.

 

#!/bin/bash 
arr=(Windows Linux Unix Mac)
i=
select a in ${arr[*]}
do
	case $a in
		"Windows")
			echo Windows以打开
			;;
		"Linux")
			echo Linux以打开
			;;
		"Unix")
			echo Unix以打开
			;;
		"Max")
			echo Max以打开
			;;
		*)
			echo error
			;;
	esac
	((i++))
done

7.

#!/bin/bash 
read -p "please enter a:" a
for((i=2;i<a;i++))
do
	if [ $(($a%$i)) -ne 0 ]
	then
		echo 是素数
	else
		echo 不是素数
		break
	fi
done

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值