设计一个检测含8或被8整除的数的C语言小程序

272关注2811浏览

1. “8”是一个吉祥的数字。凡是含有“8”或被“8”整除的数,我们都认为是吉祥数。请编写程序检测数字n(n<1000)是否是吉祥数.
供参考函数:
1).数字转字符函数
itoa(num,ch,10);//第一个参数是要转换的数字,第二个参数是要写入转换结果的目标字符串,第三个参数是转移数字时所用的基数,如10表示10进制数字.
2).字符包含函数:
strstr(str2,str1)//(功能:找出str2字符串在str1字符串中第一

共2条回答
  • Joshua
    7年前

    #include <stdio.h>
    bool islucknum( int n)
    {
        if( n%8 == 0)
            return true;
       

    0 18

  • 醉酒盛唐
    7年前

    #include <stdio.h>
    void main()
    {
    int n;
    scanf("%d",&n);
    if(n&7)
    {
    while(n%10)
    {
    if(n%10==8)
    {
    printf("YES\n");
    return;
    }
    n/=10;

    0 15

发送