问题解决基于字符串的问题,需要快速帮助 [英] Problem solving string based question, needed quick help

查看:74
本文介绍了问题解决基于字符串的问题,需要快速帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一家公司正在拥有一个网吧。如果计算机有限,许多客户访问网吧和号码。如果客户找不到可用的电脑,那么他就离开了。你给了一个带有2个参数的函数:1个计算机数,1个:带有对的字符串。第一次出现的字母表示客户的开始,第二次出现表示结束。一次只能有一个人使用电脑。返回离开咖啡馆而不使用计算机的客户的数量,以便公司可以改进流程。

示例:

进程(1,ABAB):应该返回1,因为只有1台计算机是B来自A时占用。

流程(2,ABACBCDD):应该返回0,因为所有客户A,B,C,D都可以使用Cafe。

流程(3,ABCDCDEFEFA):应该返回2,因为D和F可以使用计算机。



我尝试过:



我尝试从左到右处理它,跟踪计算机和客户的数量,但无法破解它

解决方案

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



亲自尝试,你可能会发现它不是像你想的那么难!首先尝试使用纸和笔,然后计算出您需要经历的过程。然后记下这些过程,最后按照记录下来尝试。如果可行,那么如何将它们翻译成计算机代码应该是相当明显的。



如果遇到特定问题,请询问相关问题,我们会做最好的帮助。但我们不打算为你做这一切!


例子是错误的:

进程(1,ABAB):结果应为0因为B有等到A离开并且能够使用计算机。

进程(3,ABCDCDEFEFA):结果应为0,因为同样的原因给出相同的结果。



您没有尝试自己解决问题,您毫无疑问,您的主要工作是粘贴要求,您只是希望我们做您的HomeWork。

HomeWork问题是简化版本你必须在现实生活中解决的问题,目的是学习和练习

我们不做你的HomeWork。

HomeWork不会测试你乞求别人做你的工作的技能,它会让你思考和帮助您的老师会检查您对所学课程的理解以及您应用这些课程时遇到的问题。

你的任何失败都会帮助你的老师发现你的弱点并设定补救措施。

你的任何失败都会帮助你了解什么有效,什么无效,被称为'试错'学习。

所以,试一试,重读课程并开始工作。如果您遇到特定问题,请显示您的代码并解释这个问题,我们可能会提供帮助。



作为程序员,您的工作是创建算法解决特定问题,你不能依赖别人永远为你做,所以有一段时间你必须学会​​如何。而且越快越好。

当你要求解决方案时,就像试图通过培训其他人来学习开车一样。

创建算法基本上是找到数学并做出必要的调整以适应你的实际问题。


A Company is having a number is cyber cafe. Many customer visit cyber cafe and number if computers are limited. If customer don't find available computer then he leave. You have given a function with 2 arguments : 1 number of computers, 1 : a string with pairs. 1st occurrence of alphabet indicate start of customer and second occurrence indicate end. Only 1 person can use a computer at a time. Return count of customers who left cafe without using computer so that company can improve process.
example :
process(1, ABAB) : should return 1 as only 1 computer is there that is occupied by A when B comes.
process(2,ABACBCDD) : should return 0 as all customer A,B,C, D are able to use Cafe.
process(3, ABCDCDEFEFA) : should return 2 as D and F could use computer.

What I have tried:

I tried processing it from left to right keeping track of number of computer and customer but unable to crack it

解决方案

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! Start by trying to do it with a paper and pencil, and work out the processes you need to go through. Then write down those processes and finally try them as written down. If that works, it should be fairly obvious how to translate them to computer code.

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!


Examples are wrong:
process(1, ABAB): result should be 0 because B have waited until A leave and was able to use a computer.
process(3, ABCDCDEFEFA): result should be 0 because same reason gives same result.

You show no attempt to solve the problem yourself, you have no question, your main effort is pasting the requirement, you just want us to do your HomeWork.
HomeWork problems are simplified versions of the kind of problems you will have to solve in real life, their purpose is learning and practicing.
We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
Any failure of you will help you to learn what works and what don't, it is called 'trial and error' learning.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.

As programmer, your job is to create algorithms that solve specific problems and you can't rely on someone else to eternally do it for you, so there is a time where you will have to learn how to. And the sooner, the better.
When you just ask for the solution, it is like trying to learn to drive a car by having someone else training.
Creating an algorithm is basically finding the maths and make necessary adaptation to fit your actual problem.


这篇关于问题解决基于字符串的问题,需要快速帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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