回 帖 发 新 帖 刷新版面

主题:如何设定该程序在找到第一个替换后,就不在继续向下对比?谢谢

该程序是查找相同四码并替换原来的数组,如何让该程序在查找到第一个相同四码替换输出后就不在继续向下对比?谢谢赐教!
#include<stdio.h>
void main() 
{           
int i,j,s,AA,OKKO;
int a[14][5]={
                {3,5,6,11,18},
                {2,5,6,11,18},
                {1,5,8,11,13},
                {2,4,6,11,18},
                {1,3,6,11,18},
                {4,6,8,10,18},
                {2,4,7,10,18},
                {3,4,5,10,18},
                {2,4,5,10,18},
                {1,4,5,10,18},
                {2,3,5,10,18},
                {1,2,5,10,18},
                {3,5,7,9,18},
                {1,3,6,9,22},
};
int b[14][5]={
                {1,3,6,9,18},
                {6,7,9,11,12},
                {4,7,9,11,12},
                {2,7,9,11,12},
                {1,7,9,11,12},
                {3,7,8,11,12},
                {2,5,8,11,12},
                {1,5,8,11,12},
                {2,4,6,11,12},
                {1,3,6,11,12},
                {1,5,9,11,13},
                {3,6,8,10,12},
                {3,6,8,10,11},
                {3,6,8,9,13},
                };
   for(i=0;i<14;i++)                    
    {
        for(s=0;s<14;s++)
        {
              AA=0;
            for(j=0;j<5;j++)
            {                        
            if(b[s][j]==a[j])//a数组和b数组对比
                AA++;           //有相同的就记数
                if(AA>=4)
                {
                   for(j=0;j<5;j++)
                    a[j]=b[s][j];//数组中有等于大于四个数码的将b数组的码全部赋予a数组 
                   goto loop;
                }  
            }
        } 
loop:
        {
          for(j=0;j<5;j++)
              printf("%4d",a[j]);
            printf("\n");
            OKKO++;
        }
   }
}

回复列表 (共1个回复)

沙发


把loop放到第一个for循环之外

我来回复

您尚未登录,请登录后再回复。点此登录或注册