x=0 for i in {1…100} do let x+=i done echo $x 1-100一内所有偶数的和: #!/bin/bash num=0 for i in {1…100} do a=$[i%2] if [a−eq0];thenletnum=a−eq0];thenletnum=num+$i fi done echo $num
计算1到100之间和奇数和与偶数和 #!/bin/bash Evensum=0 ODDsum=0 for i in {1..100};do if [ $(( i%2 )) -eq 0 ];then let Evensum+=$i else let ODDsum+=$i fi done echo "Evensum is $Evensum" echo "ODDsum is $ODDsum" ~ 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11....
shell脚本用while循环计算1-100偶数相加 #!/bin/bash sum=0 i=2 while (($i<=100)) do sum=$(($s 求C语言1到100的奇数和的程序 #include<stdio.h>void main(){ int i, 新开传奇新服网站,新服新开网站服,新开传奇新服网站 2023新开传奇新服网站服,新开网站服,人气火爆的新开网站服,各类新服新开网...
!/bin/bash Evensum=0 ODDsum=0 for i in {1..100};do if [ $(( i%2 )) -eq 0 ];then let Evensum+=$i else let ODDsum+=$i fi done echo "Evensum is $Evensum"echo "ODDsum is $ODDsum"~
!/bin/bash sum=0 i=2 while (($i<=100))do sum=$(($sum +$i))i=$(($i+2))done echo $sum
1-100内所有的整数的和: #!/bin/bash x=0 for i in {1..100} do let x+=i done echo $x 1-100一内所有偶数的和:#!/bin/bash num=0 for i in {1..100} do a=[ia -eq 0 ];then let num=num+i fi done echo $num 本文转自 英强云计算 51CTO博客,原文链接:http://blog.51cto.com...
#!/bin/bash x=0 for i in {1…100} do let x+=i done echo $x 1-100一内所有偶数的和: #!/bin/bash num=0 for i in {1…100} do a=$[i%2] if [a−eq0];thenletnum=a−eq0];thenletnum=num+$i fi done echo $num...