我需要有关此练习的提示 [英] I need tips about this exercise

查看:124
本文介绍了我需要有关此练习的提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好:我的工作是在这种页面的帮助下询问这个练习:



1引号是一个以引号字符开头的字符串,结束与另一个引用字符和



中间不包含引号字符。这些只是通常的(未经证实的)引用。例如,



'这是一个字符串'是1报价。



对于k 1 ,k-quotation是一个以k引号字符开头的字符串,以另一个k引号结尾



字符,并且中间包含一个嵌套字符串。嵌套字符串是一个非空的序列



(k-1)-quotations,可以在任意数量的非引号之前,分隔和成功



个字符。例如,''全部'工作'而没有'播放'''是双引号



所以我的问题是:我怎么能分开做一部分



k-quotes中的报价以及如何对k-1报价做出规则



我尝试了什么:



目前我有这段代码:



Hello: my work is ask in this kind of page help about this exercises:

A 1-quotation is a string that begins with a quote character, ends with another quote character and

contains no quote characters in-between. These are just the usual (unnested) quotations. For example,

'this is a string' is a 1-quotation.

For k 1, a k-quotation is a string that begins with k quote characters, ends with another k quote

characters and contains a nested string in-between. The nested string is a non-empty sequence of

(k − 1)-quotations, which may be preceded, separated, andor succeeded by any number of non-quote

characters. For example, ''All 'work' and no 'play''' is a 2-quotation

So my question is: how can i do the part of separate

the quotes in k-quotes and how to do the rule about the k-1 quotes

What I have tried:

For the moment i have this code:

public class String_Theory {
    private static	ArrayList<integer> numbers = new ArrayList<integer>();
    private static Scanner sca= new Scanner(System.in);
    public static void main(String[]args) {
        System.out.println("Enter a number");
        int totalNumbers=sca.nextInt();
        for(int i=0	;i<totalNumbers;i++) {
            System.out.println("Enter the number of quotes");
            int num=sca.nextInt();
            numbers.add(num);
            if(sumListsNumbers(numbers)%2!=0) {
                System.out.println("No quotation");
            }else {
                **//here i have to do the the thing of k-quotes and k-1 quotes**
            }
            enter code here
        }
    }
    public static int sumListsNumbers(ArrayList<integer> numbers) {
        int total=0;
        for (int i=0; i<numbers.size();i++) {
            total=total + numbers.get(i);
        }
        return total;
    }
}

推荐答案

提示:

1)我们不是要为你做这件事。所以你需要付出一些努力,而不是仅仅发布一个粗略的shell并添加这里我必须做k-quotes和k-1引用的事情和在这里输入代码 - 我们不是在这里做功课!

2)仔细阅读问题。然后开始考虑问题,并准备一些测试数据。然后拿一支铅笔和纸,然后手动完成。然后,写下你是如何做到的。阅读你刚才写的说明 - 他们有意义吗?如果他们这样做,请再次按照说明进行测试。你最终得到了正确的结果吗?如果你不这样做,那么修改指令直到你这样做。

当你这样做时,你有一个算法,你可以开始寻找自动化并将它变成一个应用程序。



这并不是那么复杂,不是真的 - 它需要的只是你的一点思考。祝你好运!
Tips:
1) We aren't going to do it for you. So you need to put some effort into this, instead of just posting a rough "shell" and adding "here i have to do the the thing of k-quotes and k-1 quotes" and "enter code here" - we are not here to do your homework!
2) Read the question carefully. Then start thinking about the problem, and prepare some test data. Then get a pencil and paper, and do it manually. Then, write down how you did it. Read the instructions you just wrote- do they make sense? If they do, do the tests again, following the instructions absolutely. Do you end up with the right results? If you don't, then revise the instructions until you do.
When you do, you have an algorithm, and you can start looking to automate it and turn it into an application.

This isn't that complicated, not really - all it needs is a bit of thinking on your part. Good luck!


这篇关于我需要有关此练习的提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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