很有用的C语言问题,请来看看
想把一个数高地位交换,比如10110110,把它变成01101101。怎么编呢?想了很久,请大家帮个忙……在此先谢过了!!!
main()
{
long int i,a;
scanf("%ld",&i);
do
{
a=i%10;
i=i/10;
printf("%d",a);
}while(i!=0);
}
以前有类似的贴 你查查
[color=#0000FF]# include<stdio.h> typedef struct { unsigned int a :1 ; unsigned int :6 ; unsigned int c :1 ; }tagStruct ; typedef union { char x ; tagStruct sa ; }tagUnion ; int main() { tagUnion ua ; unsigned int temp ; scanf("%d" , &ua.x) ; temp = ua.sa.a ; ua.sa.a = ua.sa.c ; ua.sa.c = temp ; printf("%d\n" , ua.x) ; return 0 ; }[/color]