循环。用个arraylist,如果两个数字相邻就写入,arraylist.count>5就...

解决方案 »

  1.   

    循环一次,然后使用字典来存放编号和他出现的次数,泛型字典
    Dictionary<string, int> dic = new Dictionary<string, int>();
      

  2.   

    1,将数字全排序。
    2,遍历原数组
    3,当指向第N个数字array[n]的时候,看一下a[n+5] == a[n] + 5
       如果是,则删除a[n] ~ a[n+5]如果是删除所有相连数字,要增加循环处理后面的“5”,让他自增到不满足条件或到末尾为止
      

  3.   

    string [] stringArray=new string(.....)//用于存放需要判断的队列string [] stringArray_new = new string[90];//用于存放判断后的队列。int j=0;//计数器
    int num = stringArray[0].toInt();//前一个数
    int num2 = stringArray[1].toInt();//后一个数int k=0;//用于结果数组的下标。
    for (int i=0;i < stringArray.length -1 ; i++)
    {
       // 判断相邻两个数据是否连号
       if (num2 == (num + 1))
       {
          j = j + 1;
       }
       else
       {
          j = 0;     
       }
       //取下一个数。
       num = stringArray[i + 1].toInt();
       num2 = stringArray[i + 2].toInt();   //如果连号,并连号超过五个数,结果数组下标回拨5,
       if (j > 5)
       {
          k = k -5;
       }
       else
       {
          stringArray_new[k] = stringArray[i];
       }
                  
    }
    以上代码未经测试,仅是思路供参考。
      

  4.   

    不考虑文件操作部分,仅从算法的角度的话,仅仅是一个思路,没有验证
    public static List<int> ModifyList(int List<int> source){
    List<int> result=new List<int>();
    int LineNum=0;while(true)
    {
    List<int> tempList=new List<int>();
    Floater=LineNum;
    tempList.Add(source[LineNum]);
    while( LineNum<=source.Count-2)

    if(source[LineNum]++== source[LineNum++])
    tempList.Add(source[LineNum]);
    else
    {
     break;
     if( LineNum-Floater<5)
    AppendToFinalList(tempList,result);
     }}
    if(LineNum==source.Count-1)
    break;}
    return result;}