#include<stdio.h>
int Invert(int n);
int Accumulate(int n);
int main()
{
int n;
int accum;
int inv;
printf("Please enter an integer:");
scanf("%d",&n);
inv = Invert(n);
accum = Accumulate(n);
printf("按位逆置为:%d\n按位累加为:%d",inv,accum);
return 0;
}
int Invert(int n){
int inv = 0;
while(n!=0){
inv = inv*10 + n % 10;
n /= 10;
}
return inv;
}
int Accumulate(int n){
int accum = 0;
while(n!=0){
accum += n % 10;
n /= 10;
}
return accum;
}
【无标题】调用函数让用户实现按位逆置和按位累加
最新推荐文章于 2024-08-13 23:31:35 发布