91学习

陪伴你每一天!

实现循环左移

#include <stdio.h>left(unsigned value,int n){ unsigned z; z=(value>>(32-n))|(value<<n); return z;}void main(){ unsigned a; int n; printf("please input a number:\n"); scanf("%o",&a); printf("please input

C语言的右移操作

#include <stdio.h>void main(){ int x=30,y=-30; x=x>>3; y=y>>3; printf("the result1 is:%d,%d\n",x,y); x=x>>2; y=y>>2; printf("the result2 is:%d,%d\n",x,y);}

C语言左移《的运算

#include <stdio.h>void main(){ int x=15; x=x<<2; printf("the result is:%d\n",x); x=x<<3; printf("the result is:%d\n",x);}

C语言的异或运算

#include <stdio.h>int main(){ unsigned result; int a,b; printf("please input a:"); scanf("%d",&a); printf("please input b:"); scanf("%d",&b); printf("a=%d,b=%d",a,b); result=a^b; printf(

C语言的取反操作

#include <stdio.h>int main(){ unsigned result; int a; printf("please input a:"); scanf("%d",&a); printf("a=%d",a); result=~a; printf("\n~a=%o\n",result); return 0;}

C语言中的或运算

#include <stdio.h>int main(){ int a=0XEFCA ,result; result=a|a; printf("a|a=%X\n",result); return 0;}

将两个人的年龄进行与运算

#include <stdio.h>void main(){ unsigned result; int age1,age2; printf("please input age1:"); scanf("%d",&age1); printf("please input age2:"); scanf("%d",&age2); printf("age1=%d,age2=%d",

用枚举enum 输出你喜欢的颜色

#include <stdio.h>enum Color{Red=1,Blue,Green} color;int main(){ int icolor; printf("请输入你喜欢的颜色编号:\n"); scanf("%d",&icolor); switch(icolor){ case Red: printf("the choice is Red\n"); break; case Blue: printf(&

共用体变量的初始化

   共用体变量中起作用的永远是最后一个放入的成员,不能对共用体变量赋值,也不能引用变量名得到一个值#include <stdio.h>#include <string.h>struct sea{ char name[64];};union season{ struct sea p;};int main(){ union season s; strcpy(s.p.name,"夏季"); printf("现在是:%s\n&q

用共用体设计一个一次只能装一种水果的罐头瓶

#include <stdio.h>#include <string.h>struct peaches{ char name[64];};struct coconut{ char name[64];};struct hawthorn{ char name[64];};union tin{ struct peaches p; struct coconut c; struct hawthorn h;};int main(){ union tin t; strcpy(t.p.