n_str = input("请输入一个自然数:") n = int(n_str) odd_num = 0 #奇数个数 even_num = 0 #偶数个数 total_num = 0 #总个数 print(n) while(n != 123): odd_num = 0 even_num = 0 total_num = len(n_str) for i in n_str: if(int(i) % 2 == 0): #偶数 even_num += 1 else: odd_num += 1 n_str = str(even_num) + str(odd_num) + str(total_num) n = int(n_str) print(n_str)
settings
unfold_less visibility play_arrow