字符比较问题 各位帮忙
来源:百度知道 编辑:UC知道 时间:2024/06/16 13:00:44
A[1] = A;
A[2] = B;
A[3] = B;
A[4] = C;
A[5] = B;
A[5] = A;
相同的 删除 输出 AB C
任何语言 都可以
A[2] = B;
A[3] = B;
A[4] = C;
A[5] = B;
A[5] = A;
相同的 删除 输出 AB C
任何语言 都可以
楼上的答案有错误,那样是不行的,两个都不行
vb代码
Dim i&
Dim A() As String
Dim strTemp As String
A = Split("A,B,B,C,B,A", ",")
For i = 0 To UBound(A)
If InStr(1, strTemp, A(i)) <= 0 Then
strTemp = strTemp & A(i)
End If
Next
MsgBox strTemp
java语言:
A=new array();
var temp;
A[1] = A;
A[2] = B;
A[3] = B;
A[4] = C;
A[5] = B;
A[6] = A;
for (int i=1,i<7,i++)
{
if (temp!=A[i])
{
temp=A[i];
document.write(temp);
}
}
vb语言
dim temp,printout
temp=""
printout=""
str="A,B,B,C,B,A"
A=split(str,",")
for i=0 to ubound(A)
if temp=trim(A(i))
temp=A(i)
printout=printout+temp
end if
next