#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; }
时间: 2024-10-07 06:13:25