码迷,mamicode.com
首页 > 其他好文 > 详细

repeat digits

时间:2015-05-02 11:13:33      阅读:126      评论:0      收藏:0      [点我收藏+]

标签:

#include <stdio.h>
#include <stdlib.h>
typedef int BOOL;
#define true 1
#define false 0
int main()
{
    BOOL digit_seen[10] = {false};
    int  digit;
    long int n;
    printf("Enter a number:");
    scanf("%ld",&n);
    while(n > 0)
    { 
        digit = n % 10;
        if(digit_seen[digit])
        {
            break;
        }
        digit_seen[digit] = true;
        n /= 10;
    }
    if(n > 0)
    {
        printf("Repeated digit. \n");
    }
    else
        printf("No repeated digit\n");
    system("pause");
    return 0;
}

 

repeat digits

标签:

原文地址:http://www.cnblogs.com/joyclub/p/4471615.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!