百度试题 题目编写一个Shell脚本,计算1~100的和。相关知识点: 试题来源: 解析 答:#!/bin/bashsum=0for num in {1..100}dolet sum+=numdoneecho sum=$sum 反馈 收藏
!/bin/bash j=0 for ((i=1;i<=100;i++));do j=$(($i+$j))done echo $j
编写一个Shell 脚本,计算100 以内不是5 整数倍的数字的和.(编程题)#!/bin/bashi=1sum=0while [i -le 100];doif [[i%
【答】程序清单如下:L0.2 prime.sh !/bin/bash SCRIPT: prime.sh AUTHOR: Zhaing&Bo DATE: 2010-11-21 REV: 1.1.A PLATFORM: Linularis PURPOSE: Read a number from the console, then print all the primes in (1~100). And at the same time calculate the sum of all the...