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

2024-11-28 10:32:51
推荐回答(1个)
回答1:

源码:
==============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===============