【发布时间】:2021-10-12 23:05:08
【问题描述】:
给你的程序定义了一个包含 10 个单词的数组,并以一个字母作为输入。 编写一个程序来遍历数组并输出包含所取字母的单词。 如果没有这个词,程序应该输出“No match”。
示例输入
u
样本输出
fun
/////////////////////////////////////////The Code I did comes after this//////////////////
using System;
using System.Collections.Generic;
namespace Code_Coach_Challenge
{
class Program
{
static void Main(string[] args)
{
string[] words = {
"home",
"programming",
"victory",
"C#",
"football",
"sport",
"book",
"learn",
"dream",
"fun"
};
string letter = Console.ReadLine();
for (int count = 0; count < 10; count++)
{
if (words.Contains(letter)) { Console.WriteLine(words[count]); }
else
{
Console.WriteLine("No match");
}
}
}
}
}
【问题讨论】: