大家好:
现在两个字符串s1='111111111100',s2='00011111011'.请问如何用delphi 写程式,使s1和s2
进行或运算得到字符串s3:='111111111111',s1和s2进行与运算得到字符串s4:='00011111000'
thanks
现在两个字符串s1='111111111100',s2='00011111011'.请问如何用delphi 写程式,使s1和s2
进行或运算得到字符串s3:='111111111111',s1和s2进行与运算得到字符串s4:='00011111000'
thanks
解决方案 »
- 2001年离开“猪圈”(某军工厂),如果我的獠牙快长出了。
- 急救!窗体打开问题。
- 逐条处理200万条记录,什么方法较好?
- 谁有jabber的源码?或下载网址,谢谢:)
- 为什么日期型字段,在绑定后,保存会产生在数据库中存成'0000-00-00',这个的日期
- 如何整合一系列exe程序
- oracle中,设定varchar2长度为4000,(最大只能存4000),为什么存到1333就不行了,多一个都不行,报 ORA-01480:trailling missing from STR bin
- 寻兼职开发人员几名
- ★TreeView控件用法,两小问★
- 诚邀Delphi兼职开发人员1人
- 修复paradox数据表
- 执行数据库
function StrOr(const S1, S2: string): string;
var
I: Integer;
P1, P2: Integer;
begin
Result := '';
if S1 = '' then Result := S2
else if S2 = '' then Result := S1
else begin
P1 := Length(S1);
P2 := Length(S2);
while (P1 > 0) or (P2 > 0) do
begin
if P1 <= 0 then Result := S2[P2] + Result
else if P2 <= 0 then Result := S1[P1] + Result
else begin
if (S1[P1] = '1') or (S2[P2] = '1') then Result := '1' + Result
else Result := '0' + Result;
end;
Dec(P1);
Dec(P2);
end;
end;
end;function StrAnd(const S1, S2: string): string;
var
I: Integer;
P1, P2: Integer;
begin
Result := '';
if (S1 = '') or (S2 = '') then Result := '' //其中一个为空,返回空?
else begin
P1 := Length(S1);
P2 := Length(S2);
while (P1 > 0) and (P2 > 0) do
begin
if (S1[P1] = '1') and (S2[P2] = '1') then Result := '1' + Result
else Result := '0' + Result;
Dec(P1);
Dec(P2);
end;
end;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(StrOr('111111111100', '00011111011'));
ShowMessage(StrAnd('111111111100', '00011111011'));
end;