要求:提示用户键入一个字符串以及一个数字,分两行键入,然后以数字为重复次数,输出输入的数字行字符串。例如,你输入了字符串为"aaa", 输入的数字为5, 那么输出结果应为
aaa
aaa
aaa
aaa
aaa
以下为程序代码:
aaa
aaa
aaa
aaa
aaa
以下为程序代码:
- #! /usr/bin/perl
- print "Please input a character string:\n";
- $c=;
- print "Please input a number:\n";
- chomp ($n=);
- print $c x $n;
0
#!/bin/bash
read -p "please input your string: " -t 5 x
read -p "please input your num: " -t 5 y
if [ $y -gt 0 ]
then
for i in `seq 1 $y`
do
echo $x
done
else
echo "your num isIllege"
fi
read -p "please input your string: " -t 5 x
read -p "please input your num: " -t 5 y
if [ $y -gt 0 ]
then
for i in `seq 1 $y`
do
echo $x
done
else
echo "your num isIllege"
fi
0
GaryHuang0113 - 世上无难事,只怕有心人
#!/bin/bash
read -p "please input your string: " -t 5 str
read -p "please input your num: " -t 5 count
for ((i=0;i<$count;i++))
do
echo $str
done
read -p "please input your string: " -t 5 str
read -p "please input your num: " -t 5 count
for ((i=0;i<$count;i++))
do
echo $str
done
编辑回复