其余案例没有发生递归

时间:2017-07-28 12:46:19

标签: c++ loops recursion

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int a[102][102]={0};int b[100]={0};int ans=0;
int find(int i,int j,int n)
{
    if(j>n)
    {
        return 0;
    }
    if(a[i][j]==1)
    {
        cout<<j<<endl;
        int s=find(j,0,n);
        if((s+1)%2==0&&s!=0)
        {
            ans++;
        }
        return s+1;
    }
    int s=find(i,j+1,n);
}

int main() {

    int i,j,n,m;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        a[y][x]=1;
    }

        int s=find(1,0,n);
        cout<<ans<<endl;

    return 0;
}

我在图表上尝试了一个问题并且遇到了问题。 j的剩余值没有发生递归,其中a [i] [j] = 1。它始终只针对第一种情况。你们中的任何人可以帮我解决这个问题吗?

0 个答案:

没有答案