openjudge大一敲七问题错在了哪

img


#include<iostream>
using namespace std;
int main()
{
    int N,x,y,z;
    cin>>N;
    for(x=1;x<=N;x++)
{   z=x;
    if(z%7==0)
    cout<<x<<endl;
    else
    while(z>0)
{   y=z%10;
    z/=10;
    if(y==7)
    cout<<x<<endl;
    break;}
}
    return 0;
}

18行break应该放在if的{}里

仅供参考,望采纳~

#include<iostream>
using namespace std;
int main()
{
    int N,x,y,z;
    cin>>N;
    for(x=1;x<=N;x++)
    {   
        z=x;
        if(x%7==0)
        {
            cout<<x<<endl;
        }
        else
        {
            while(z>0)
            {   y=z%10;
                z/=10;
                if(y==7)
                {
                    cout<<x<<endl;
                    break;
                }
            }
        }
    }
    return 0;
}