两个长度都为500的1010101010...1100串,"按位与"后的结果(二进制形式)有多少个1
两个长度都为500的1010101010...1100串, "按位与 "后的结果(二进制形式)有多少个1
------解决方案--------------------select top 500 IDENTITY(int,1,1) as id into # from syscolumns a,syscolumns b
declare @s1 varchar(500)
declare @s2 varchar(500)
set @s1= '10101010101100010101000011011011001 '
set @s2= '10100010110110010110011001100111110 '
select count(*)
from #
where substring(@s1,id,1)= '1 ' and substring(@s2,id,1)= '1 '
drop table #
--结果
-----------
10
(所影响的行数为 1 行)