放到一个数组str中
int i=0;
string a1,a2;
while(true){
  if (i>4){
     i=0;
  }
  a1=str[i]
  if (i+1>4){
     i=-1;
  }
  a2=str[i+1];
  i=i+2;
  do sth with a1和a2
}

解决方案 »

  1.   

    要写一个方法处理,否则会出现死循环
    class xx
    {
    int count;
    String[] yy;
    String[] str[]=("a","b","c","d");
    public void xx()
    {
      for(int i=0;i<2;i++
    {
      if(count=5)
        count=1;
      yy[i]=str[count-1];
     }
    }
    }
      

  2.   

    String[] str[]=("a","b","c","d");
    应为String[] str={"a","b","c","d"};
      

  3.   

    class xx{
    string[] str={"a","b","c","d"};
    string a1,a2;
    int count=0;
    while(ture)
      { if(count>4) count=0;
        a1=str[count];
        count++;
        if(count>4) count=0;
        a2=str[count];
        count++;
        //do sth with a1 and a2.
       }
    }