s:string; if s in ['0'..'9''] then 错误为:不是Char(50分)

  • 主题发起人 主题发起人 w_yt1977
  • 开始时间 开始时间
W

w_yt1977

Unregistered / Unconfirmed
GUEST, unregistred user!
var
s:string;
begin
if s in ['0'..'9''] then
end;
错误为:不是Char
 
看看set的定义,就知道为什么了。
A set is a collection of values of the same ordinal type.
The values have no inherent order, nor is it meaningful
for a value to be included twice in a set.
The range of a set type is the power set of a specific
ordinal type, called the base type;
that is, the possible
values of the set type are all the subsets of the base type,
including the empty set. The base type can have no more than
256 possible values, and their ordinalities must fall between
0 and 255
 
你确实错了!
应该这样
var
s:string;
i:integer;
begin
s:='121313';
for i:=1 to length(s) do
if s in ['0'..'9''] then
end;
 
字符串跟字符是两回事,张无忌的做法是正确的。
 
先给 s 赋值就行了
 
接受答案
 
接受答案
 
后退
顶部