# 高分请哪位仁兄指教一下，小弟刚学编程。

cl10270517 2006-04-21 09:21:58

...全文
241 17 点赞 打赏 收藏 举报

17 条回复

cl10270517 2006-04-21

• 打赏
• 举报

kissknife 2006-04-21

• 打赏
• 举报

kissknife 2006-04-21

int count = 0;
bool sign=false;

for (int i = 0; i < s.Length; i++)
{
char c = s[i];
if (!sign && (c == '(' || c == ')' || c == '（' || c == '）'))
{
sign = true;
}

if ((s.LastIndexOf(',')<i || c == ',') && sign == true)
{
sign = false;
continue;
}

if (!sign && c != ',')
{
count++;
}
}

• 打赏
• 举报

zhf777 2006-04-21

• 打赏
• 举报

comeon_data 2006-04-21

• 打赏
• 举报

comeon_data 2006-04-21
int totalLength = str.Length ;

int result = totalLength ;
bool target1 = false ;
bool target2 = false ;
int target1Position = 0 ;
for( int i = 0 ; i < totalLength ; i ++ )
{
switch( str.Substring( i , 1 ) )
{
case "(" :
if( !target1 )
{
target1Position = i ;
target1 = true ;
}
break ;
case ")":
if( !target1 )
{
target1Position = i ;
target1 = true ;
}
break ;
case "," :
if( !target2 && target1 )
target2 = true ;
break ;
default:break ;
}
if( target1 && target2 )
{
result -= ( i - target1Position ) ;
target1 = false ;
target2 = false ;
}
}
Label1.Text = result.ToString() ;
• 打赏
• 举报

limengqiang 2006-04-21

orgId=orgId.Substring(0,orgId.Length-1);
string temp=string.Empty;
string []orgItem=orgId.Split(',');
for(int i=0;i<orgItem.Length;i++)
{
temp=temp+"'"+orgItem[i]+"',";
}
orgId=temp.Substring(1,temp.Length-3);
return orgId;
• 打赏
• 举报

LixingTie 2006-04-21
int count = 0;
bool go = true;
foreach (char x in A)
{
if (x == '(') go = false;
if (x == ',')
{
go = true;
continue;
}
if(go) count++;
}
• 打赏
• 举报

cl10270517 2006-04-21

• 打赏
• 举报

iversonkai 2006-04-21

• 打赏
• 举报

xiao635113 2006-04-21

• 打赏
• 举报

cl10270517 2006-04-21

• 打赏
• 举报

comeon_data 2006-04-21

• 打赏
• 举报

cl10270517 2006-04-21

• 打赏
• 举报

cl10270517 2006-04-21

• 打赏
• 举报

liujiayu10 2006-04-21

• 打赏
• 举报

cl10270517 2006-04-21

• 打赏
• 举报

C#

10.6w+

.NET技术 C#

2006-04-21 09:21