使用关键字匹配输入的句子 [英] Do the matching of the entered sentence using keyword

查看:111
本文介绍了使用关键字匹配输入的句子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意:对我来说翻译有点不好但是不要抬头



我正在编写一个程序,现在我将输入一个文本程序和使用此关键字来匹配此文本是与课程相关但我遇到问题

我已经定义了一个关键字我已经分配了一个变量名

int a

Console.Write(输入你的句子);

a = Convert.Toint32(Console.ReadLine());

if (关键字== a)

{

与数学相关的句子

这里的问题是程序单词不是单词但它是整个cümlenle我的目的是将单词与cümlen的单词逐一比较如何从这里开始我尝试拆分命令但我没有成功



< b>我尝试过:



Note: it will be a little bad for me to translate but do not look up

I am writing a program and now I will enter a text in the program and using this keyword to match this text is something related to the lessons but I'm having a problem
I have defined a key word I have assigned a variable name
int a
Console.Write ("Enter Your Sentence");
a = Convert.Toint32 (Console.ReadLine ());
if (keyword == a)
{
Sentence related to mathematics
here the problem is the program word is not the word but it is the whole of the cümlenle my aim is to compare the words with the words of the cümlen one by one how to start here i tried split command but i was not successful

What I have tried:

Console.Write ("Enter Your Sentence");
a = Convert.Toint32 (Console.ReadLine ());
if (keyword == a)
{

推荐答案

返回string.Split解决方案 - 什么你没有工作,也不会。

你读了一行,但是你试着把它转换成一个整数 - 而且字通常根本不能转换为数字。到目前为止我输入的句子都没有包含一个可以转换为整数的单词!

String.Split方法(Char [])(系统) [ ^ ]



所以从这开始:

Go back to the string.Split solution - what you have doesn't work, and won't.
You read a line, but then you try to convert it to an integer - and words don't normally convert to numbers at all. None of the sentences I have typed so far even contain a word that would convert to an integer!
String.Split Method (Char[]) (System)[^]

So start with this:
Console.Write ("Enter Your Sentence: ");
string input = Console.ReadLine ();
string[] words = input.Split(' ');

看看你是否可以自己完成下一步。

And see if you can do the next bit yourself.


这篇关于使用关键字匹配输入的句子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆