rupweb(rupweb) 每一个数都是3、1或0,当然是1位呀!
解决方案 »
- datagrid编辑列问题**************
- 一个正三角形,边长是70 在这个正三角形的任一边为弦,画园弧(在内),园半径是75 请问在A区域放三个相同的园,都与园弧相切且两两相切, 这三个园要放多大呀??
- 导入pdf文件
- 报表问题,急求解!!!!!
- 数组排序,求代码
- ExecuteNoQuery的受影响行数的问题
- webbrowse控件怎么使用
- 两个关于.NET2005下D3D游戏的问题,请教高手,100分敬赠
- 资深OWC专家请进: ---用OWC制作交会图,类型为气泡图,生成的是标准的气泡图,我要将背景色设为白色, 标上气泡大小,气泡设置为无填充,无边框
- C# winform TreeView 为不同节点设置不同高度?
- C#操作SQL Server库,数据不写回到数据库,为什么?
- 如何实现先进的新闻系统,欢迎大家讨论!
结果:iThree应该为1,iOne应该为1,iZero应该为0
string strTest="111300010033310";
int iThree=0;
int iOne=0;
int iZero=0; for(int i=0;i<strTest.Length;i++)
{
if(strTest[i]=='3')
{
int iCount=0;
for(int j=i+1;j<strTest.Length;j++)
{
if(strTest[i]==strTest[j])
{
iCount++;
}
else
{
i=j-1;
break;
}
}
if(iCount>0)
{
iThree++;
}
}
else if(strTest[i]=='1')
{
int iCount=0;
for(int j=i+1;j<strTest.Length;j++)
{
if(strTest[i]==strTest[j])
{
iCount++;
}
else
{
i=j-1;
break;
}
}
if(iCount>0)
{
iOne++;
}
}
else if(strTest[i]=='0')
{
int iCount=0;
for(int j=i+1;j<strTest.Length;j++)
{
if(strTest[i]==strTest[j])
{
iCount++;
}
else
{
i=j-1;
break;
}
}
if(iCount>0)
{
iZero++;
}
}
}
“结果:iThree应该为1,iOne应该为1,iZero应该为0”
应该改为:
“结果:iThree应该为1,iOne应该为1,iZero应该为2”
偶想过了,偶是拿JAVA实现的,可惜代码偶找不到了!其实就是按位比较将A放入T中,将B与T比,相同做类加,不同T不变,继续找。遍历13位就OK了。
using System.Text.RegularExpressions;class Statistic{
static void Main(){
string orignal = "1133003000333";
string pattern = @"(0{2,})|(1{2,})|(3{2,})";
Regex reg = new Regex(pattern);
Match m = reg.Match(orignal);
int[] result = new int[3];
for(int i = 0; i < result.Length;i++)
result[i] = 0;
while(m.Success){
string mV= m.Value;
int len = mV.Length;
switch(mV[0]){
case '0':
result[0] = Math.Max(result[0],len);
break;
case '1':
result[1] = Math.Max(result[1],len);
break;
case '3':
result[2] = Math.Max(result[2],len);
break;
}
m = m.NextMatch();
}
foreach(int r in result)
Console.WriteLine(r);
}
}
for(int i = 0; i < result.Length;i++)
result[i] = 1;非常感谢!马上给分!