这道练习题出自《C语言程序设计与方法》
#include <stdio.h>
#include <stdbool.h>
/*这个程序用到了bool、true和 false 等名称,它们在C99的 < stdbool.h>中定义。如果你的编译器不支持该头
需要自己定义这些名称。一种做法是在 main 函数的上面加上下面几行:
#define true 1
#define false 0
typedef int bool; */
int main(void)
{
bool digit_seen[10] = {false};
int digit;
long 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 digite\n");
else
printf("No repeated digit\n");
return 0;
}