C语言:输出1-1000间至少有一位为7的所有数

#include <stdio.h>
int bh(int s,int a)
{
    while(s)
    {
        if(s%10==a) return 1;
        s=s/10;
    }
    return 0;
}
main()
{
    int sum=0,a,b,c;
    for(a=1;a<=1000;a++)
    if(bh(a,7)==1)printf("%d ",a);getchar();
 }

 

posted @ 2022-01-07 15:44  myrj  阅读(165)  评论(0编辑  收藏  举报