1.思维导图
2.练习
1.定义一个find函数,查找ubuntu和root的gid
2.定义一个数组,写一个函数完成对数组的冒泡排序
cpp
bubble()
{
n=${#arr[*]}
for((i=0;i<n-1;i++));do
for((j=0;j<n-1-i;j++));do
if ((arr[j]>arr[j+1]));then
temp=${arr[j]}
arr[j]=${arr[j+1]}
arr[j+1]=$temp
fi
done
done
}
arr=(5 8 2 4 7)
echo befor ${arr[*]}
bubble
echo after ${arr[*]}
3.break求1-100质数 :
cpp
#!/bin/bash
for ((num=2;num<100;num++));do
flag=1
for ((i=2;i*i<=num;i++));do
if ((num%i==0));then
flag=0
break
fi
done
if ((flag==1));then
echo -n "$num "
fi
done
echo