用位运算 把输入数字所有的1找到 然后判断是2的几次方
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
while(n){
int t = n & -n;
n -= t;
int cnt = 0;
while(t > 1){
t /= 2;
cnt ++;
}
char x = 'a';
x += cnt;
cout << x;
}
return 0;
}

京公网安备 11010502036488号