一开始是一个数字N. [英] At the beginning a number N

查看:62
本文介绍了一开始是一个数字N.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一开始会给出一个数字N. N段将随后出现。对于每个段落,您必须找到以下内容:

i)段落中有多少篇文章(含义的语法含义)。这意味着有多少'a',多少'an'和多少'

ii)段落中有多少日期信息。 (此任务的日期定义为具有所有组件的信息的日期 - 月,月和年)。请注意,日期可以用不同的方式表示:2014年12月12日,2014年6月31日,2014年7月15日,2014年7月15日,2014年7月15日,2014年7月15日,2014年7月15日,12月15日,2015等...你可以处理的品种越多,你的结果就越准确



示例输入:



3

法国大革命是法国历史上一场影响深远的社会和政治动荡时期,从1789年持续到1799年,并且在后来的扩张期间被拿破仑部分推进。法国帝国。

德拉敦是印度北部北阿坎德邦的首府。位于Garhwal地区,位于印度首都新德里以北236公里(147英里)。

2014年印度大选被认为是第16届Lok Sabha,为所有议员选举议员543个印度议会选区。这是2014年4月7日至2014年5月12日的九个阶段,是该国历史上最长的选举。根据印度选举委员会的统计,自2009年上次大选以来,有8.14亿人有资格投票,增加了1亿选民,使其成为世界上有史以来规模最大的选举。



输出将是:



1,0,3,0

0,0,4, 0

0,1,8,2



说明:第一段(关于法国革命)在'a'上有1次出现, 0出现'an','3'出现'the'和0出现''date information。'与其他两段相同。



什么我试过了:



i没有尝试太多...没有多少时间尝试任何东西

At the beginning a number N will be given. N number of paragraphs will follow. For each paragraph you have to find the following:
i) How many articles (grammatical meaning implied) of each type are there in the paragraph. That means how many 'a', how many 'an' and how many 'the'
ii) How many date information is there in the paragraph. (A date for this task is defined as one which has the information of all the components- date, month and year). Be aware that a date can be expressed in different ways: 12/07/2014, 06/31/2014, 6-31-2014, 15 July, 2014, 15 Jul 2014, 15th July 2014, 15th of July 2014, December 15, 2015 etc....the more variety you can handle the more accurate your result will be

Example input:

3
The French Revolution was a period of far-reaching social and political upheaval in France that lasted from 1789 until 1799, and was partially carried forward by Napoleon during the later expansion of the French Empire.
Dehradun is the capital city of the state of Uttarakhand in the northern part of India. Located in the Garhwal region, it lies 236 kilometres (147 miles) north of India's capital New Delhi.
The Indian general election of 2014 was held to constitute the 16th Lok Sabha, electing members of parliament for all 543 parliamentary constituencies of India. Running in nine phases from 7 April 2014 to 12 May 2014, it was the longest election in the country's history. According to the Election Commission of India, 814.5 million people were eligible to vote, with an increase of 100 million voters since the last general election in 2009, making it the largest-ever election in the world.

The output will be:

1,0,3,0
0,0,4,0
0,1,8,2

Explanation: The first paragraph (on French revolution) has 1 occurrence on ‘a’, 0 occurrence of ‘an’, ‘3’ occurrences of ‘the’ and 0 occurrences of ‘date information.’ Same for other two paragraphs.

What I have tried:

i have not tried much...got too less time to try anything

推荐答案

如果时间很短,那么你最好快速行动。否则你将无需交付......

我们不做你的功课:这是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



亲自尝试,你可能会发现它不是和你想的一样困难!



如果遇到具体问题,请询问相关问题,我们会尽力提供帮助。但我们不打算为你做这一切!
If time is short, you had better get moving fast then. Otherwise you will have nothing to hand in...
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!


与任何其他编程任务一样,你需要将问题分成更小的部分。



1.将文本拆分成段落。

你已经知道其中有3个,但你需要找出段落的区别。

看一下点(。)后跟换行符(\\ n)或回车符+换行符(\\\\ n)。

这里 strtok() [ ^ ]。



2.现在你可以使用循环并搜索每个段落关键词。

您可以使用 strstr() [ ^ ]循环,直到函数返回NULL。
为每个关键字执行此操作。



提示。不要只找'a'字母,寻找a(每边都有空格)。



使用正则表达式可以轻而易举地解决这个问题,但这可能有点太高级。



这应该可以帮助你入门。
As with any other programming task you need to divide the problem into smaller pieces.

1. Split up the text into paragraphs.
You already know there are 3 of them, but you need to find out what separates the paragraphs.
Have a look at a dot (.) followed by a line feed (\n) or carriage return + line feed (\r\n).
Here strtok()[^] could be used.

2. Now you can use a loop and search through each paragraph for your key words.
You can use strstr()[^] in a loop until the function returns NULL.
Do this for each keyword.

Hint. Don't look for the letter 'a' only, look for " a " (spaces on each side).

Using Regular Expressions would solve this problem in a breeze, but that is probably a bit too advanced.

This should help you getting started.


这篇关于一开始是一个数字N.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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