我需要找到用户使用whis函数进入系统(输入)的beginnig,$ in the center和len结尾的$序列:
public static boolean isSequence$$$(char arr[],int len){
double x = (len/2);
int y =(int)(x);
if(len % 2 == 0){
return false;
}
for(int i=0;i<arr.length;i++){
if(arr.length - i >= len){
if(arr[i] == '$' && arr[i+y] == '$' && arr[i+(len-1)] == '$' ){
return true;
}
}
}
return false;
}
我这样做但是没有用:
public static int NumOfSequences$$$(char arr[]){
int count = 0;
int j = 0;
for(int i=0;i<arr.length;i++){
if(isSequence$$$(arr,j)){
count++;
j++;
}
j++;
}
return count;
}
public static void main(String[] args) throws IOException {
char arr[] = new char[9];
arr[0] = '$';
arr[1] = '2';
arr[2] = '$';
arr[3] = '4';
arr[4] = '$';
arr[5] = '8';
arr[6] = '$';
arr[7] = '7';
arr[8] = '$';
System.out.println(NumOfSequences$$$(arr));
}