Classical C Language Test-search for multiple-digit repetition numbers and times
Input a multi-digit integer on the keyboard and use the program to check whether there are repeated numbers and repeated numbers in the number.
Example: input: 1122431
Print result:
1 repeat three times
2 repeat twice,
Code:
# Include
// Search for multiple-digit repeated numbers and times int main () {long n = 0; printf ("enter a multiple-digit number:"); scanf ("% d", & n ); int s [10] = {0}; // record the number of occurrences of the corresponding number while (n> 0) {s [n % 10] = s [n % 10] + 1; // 1123 n = n/10 ;} // print the number of times greater than 1 in the traversal array int I = 0; for (I = 0; I <10; I ++) {if (s [I]> 1) {printf ("% d repeated % d times \ n", I, s [I]) ;}} return 0 ;}
Running result:
1122431
1 repeat three times
2 repeat twice,