【发布时间】:2018-10-03 20:31:30
【问题描述】:
帮助验证 Pascal 语言输入过程的正确性。请。
标识符、双引号括起来的字符串常量和单引号括起来的单个字符都可以作为参数。
是的
proc1('s',13,"sss");
proc2('s',s,d,11,"sss");
proc3("sss");
错误
proc1(s',11,"sss");
proc2('s',s,d,11,sss");
proc3("sss);
proc4("sss";
我可怜的尝试:
public void ThreadPoolCallback(Object threadContext)
{
if ((str.Length == 0) && (str[str.Length - 1] != ')'))
{
haveError = true;
}
else
{
int startIndex = str.IndexOf('('),
lastIndex = str.LastIndexOf(')'),
startIndex2 = str.LastIndexOf('('),
lastIndex2 = str.IndexOf(')');
if (startIndex < lastIndex && startIndex > 0 && lastIndex == str.Length - 1 &&
startIndex == startIndex2 && lastIndex == lastIndex2)
{
int curr = startIndex + 1;
while (curr < lastIndex)
{
string s = "";
while (str[curr] != ',' && curr < lastIndex)
{
s += str[curr];
curr++;
}
curr++;
}
}
else
{
haveError = true;
}
}
doneEvent.Set();
}
【问题讨论】:
-
您的
str变量是否包含proc和一个数字? -
对不起。我不明白你的