编写一个程序,由用户输入一个含有5个单词的英文句子,按照用户的要求输出句中的第I个单词。

2024-12-01 08:10:40
推荐回答(1个)
回答1:

给你个Perl源码:
==============CODE===============
#!usr/bin/perl
print "Please enter a sentence containing 5 words:\n";
$sentence = ;
print "\nWhich word do you want to print?\nEnter a number from 1 to 5:\n";
$num = ;
@words = split /\s+/, $sentence;
print "The word is:\t$words[$num-1]\n";
==============CODE===============