字符串值问题 [英] problem in string value

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

问题描述


请帮帮我,我无法理解这段代码中的问题.

代码:

Hi,
Please help me out, I can''t understand whats the problem in this code.

CODE:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NFAtoDFA
{
    class Program
    {
        public static string[,] ArrOfAllStates = new string[11, 3];
        static string state;
        static string s3;
        public static void Main(string[] args)
        {
            ArrOfAllStates[0, 0] = "1,2,4,7";            //for empty
            ArrOfAllStates[0, 1] = null;              //for a
            ArrOfAllStates[0, 2] = null;              //for b
            //for state 1 of NFA
            ArrOfAllStates[1, 0] = "2,4";            //for empty
            ArrOfAllStates[1, 1] = null;              //for a
            ArrOfAllStates[1, 2] = null;              //for b
            //for state 2 of NFA
            ArrOfAllStates[2, 0] = null;            //for empty
            ArrOfAllStates[2, 1] = "3";              //for a
            ArrOfAllStates[2, 2] = null;              //for b
            //for state 3 of NFA
            ArrOfAllStates[3, 0] = "1,2,4,6,7";            //for empty
            ArrOfAllStates[3, 1] = null;              //for a
            ArrOfAllStates[3, 2] = null;              //for b
            //for state 4 of NFA
            ArrOfAllStates[4, 0] = null;            //for empty
            ArrOfAllStates[4, 1] = null;              //for a
            ArrOfAllStates[4, 2] = "5";              //for b
            //for state 5 of NFA
            ArrOfAllStates[5, 0] = "1,2,4,6,7";            //for empty
            ArrOfAllStates[5, 1] = null;              //for a
            ArrOfAllStates[5, 2] = null;              //for b
            //for state 6 of NFA
            ArrOfAllStates[6, 0] = "1,2,4,7";            //for empty
            ArrOfAllStates[6, 1] = null;              //for a
            ArrOfAllStates[6, 2] = null;              //for b
            //for state 7 of NFA
            ArrOfAllStates[7, 0] = null;            //for empty
            ArrOfAllStates[7, 1] = "8";              //for a
            ArrOfAllStates[7, 2] = null;              //for b
            //for state 8 of NFA
            ArrOfAllStates[8, 0] = null;            //for empty
            ArrOfAllStates[8, 1] = null;              //for a
            ArrOfAllStates[8, 2] = "9,10";              //for b
            //for state 9 of NFA
            ArrOfAllStates[9, 0] = null;            //for empty
            ArrOfAllStates[9, 1] = null;              //for a
            ArrOfAllStates[9, 2] = "10";              //for b
            //for state 10 of NFA
            ArrOfAllStates[10, 0] = null;            //for empty
            ArrOfAllStates[10, 1] = null;              //for a
            ArrOfAllStates[10, 2] = null;              //for b
            ////////////////////////
            Move(E_Closure(0));
        }
        public static string E_Closure(int i)
        {
            Console.Write("Enter state name:");
            state = Console.ReadLine();
            state = ArrOfAllStates[i, 0];
            i++;
            return state;
        }
        public static void Move(string s)
        {
            string[] str = s.Split(',');
            string[] s1=new string[str.Length];
            for(int m=0;m<str.Length;m++)
            s1[m] = ArrOfAllStates[int.Parse(str[m]), 1]+"," + E_Closure(int.Parse(ArrOfAllStates[int.Parse(str[m]), 1]));// exception raised
            
            foreach (string s2 in s1)
                s3 = s2;
            Console.WriteLine("State= {" + s3 + " }");
        }
        
    }
}

推荐答案

farah javed写道:
farah javed wrote:

Console.Write( 输入州名:");
状态= Console.ReadLine();
状态= ArrOfAllStates [i,0];

Console.Write("Enter state name:");
state = Console.ReadLine();
state = ArrOfAllStates[i, 0];


对我来说,此序列不合逻辑.


This sequence looks illogical to me.


代码的问题在于,这完全不是编程.编程是关于抽象和代码重用的,但是您多次重复几乎相同的代码片段,并认为有人会自愿阅读.您甚至都没有解释您似乎有什么问题.

至少在非常基础的水平上学习一些编程.看一些好的代码;它应该给你一些想法.开始编程,遇到无法解决自己的问题,然后回来.

—SA
The problem of the code is that this is not programming at all. Programming is about abstraction and code re-use, but you''re repeating almost identical fragments of code many time and think that someone will volunteer to read that. You don''t even explain what seems to be a problem to you.

Learn some programming at least on a very elementary level. Look at some good code; it should give you some ideas. Start programming, face some problem you cannot resolve your self, then come back.

—SA


我不知道代码出了什么问题(因为我没有去看它),但是我会告诉您的问题出了什么问题.您没有指定您期望代码执行的操作以及实际执行的操作.您也未提供任何错误消息(如有).
I have no idea what''s wrong with the code (because I didn''t bother to look at it), but I will tell you what''s wrong with your question. You didn''t specify what you were expecting the code to do and what it is actually doing. You also didn''t provide any error messages, if any.


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

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