A number, each digit Numbers are not the same as beautiful, such as 5640, a repeat Numbers are not, such as 11100, a given range from 1 to 100000, the input is doing this in a range between a neighborhood, then output in this area between number is beautiful, how many have computing complexity requirements, namely algorithm must be concise, which bosses can make, save me,,
CodePudding user response:
Because the largest number is 100000, don't repeat maximum number is 98765, with a maximum of five elements of the array and a said the total number of variables is ok, don't have to dynamic array, efficiency is also high, A number % 10 bits, in addition to October to remove bits, constantly put the bits in the array, there have been repeated exits, every bit not repeat number, is beautiful,
CodePudding user response:
Concise words:
Int ibn (unsigned int n) { For (int r, m=0; N; N/a=10) If (r=n % 10, (m & gt;> R) & amp; 1? 1: (m |=1 & lt; Return n==0; }
The return value 1 is beautiful, 0 is not beautiful, the rest of the test range you write yourself