免费建站平台哪个好,在珠海注册公司需要什么资料,wordpress twentyten,wordpress 上传腾讯云只能说没有一道题是自己写的#xff0c;都是在网上查资料抄别人的#xff0c;也不知道这有什么意思。也不知道自己学到了什么#xff0c;怎么说呢#xff0c;Emmmm......对了#xff0c;文末最后的几段话是为了凑字数#xff0c;大家简单忽略掉就好。
/* * tmin - retur… 只能说没有一道题是自己写的都是在网上查资料抄别人的也不知道这有什么意思。也不知道自己学到了什么怎么说呢Emmmm......对了文末最后的几段话是为了凑字数大家简单忽略掉就好。
/* * tmin - return minimum twos complement integer * Legal ops: ! ~ ^ | * Max ops: 4* Rating: 1*/
int tmin(void) {return 131;
}
/* * absVal - absolute value of x* Example: absVal(-1) 1.* You may assume -TMax x TMax* Legal ops: ! ~ ^ | * Max ops: 10* Rating: 4*/
int absVal(int x) {int s x31;return (xs)^s;
}
/* * bitAnd - xy using only ~ and | * Example: bitAnd(6, 5) 4* Legal ops: ~ |* Max ops: 8* Rating: 1*/
int bitAnd(int x, int y) {return ~(~x|~y);
}
/* * replaceByte(x,n,c) - Replace byte n in x with c* Bytes numbered from 0 (LSB) to 3 (MSB)* Examples: replaceByte(0x12345678,1,0xab) 0x1234ab78* You can assume 0 n 3 and 0 c 255* Legal ops: ! ~ ^ | * Max ops: 10* Rating: 3*/
int replaceByte(int x, int n, int c) {int s n3;return (cs)|(x~(0xffs));
}
/** mult3div2 - multiplies by 3/2 rounding toward 0,* Should exactly duplicate effect of C expression (x*3/2),* including overflow behavior.* Examples: mult3div2(11) 16* mult3div2(-9) -13* mult3div2(1073741824) -536870912(overflow)* Legal ops: ! ~ ^ | * Max ops: 12* Rating: 2*/
int mult3div2(int x) {x (x1);return (x((x31)1))1;
}
/** multFiveEighths - multiplies by 5/8 rounding toward 0.* Should exactly duplicate effect of C expression (x*5/8),* including overflow behavior.* Examples: multFiveEighths(77) 48* multFiveEighths(-22) -13* multFiveEighths(1073741824) 13421728 (overflow)* Legal ops: ! ~ ^ | * Max ops: 12* Rating: 3*/
int multFiveEighths(int x) {x (x2);return (x((x31)7))3;
}
/* * addOK - Determine if can compute xy without overflow* Example: addOK(0x80000000,0x80000000) 0,* addOK(0x80000000,0x70000000) 1, * Legal ops: ! ~ ^ | * Max ops: 20* Rating: 3*/
int addOK(int x, int y) {return (((x^y)31)|~(((xy)^x)31))1;
}
/** bitCount - returns count of number of 1s in word* Examples: bitCount(5) 2, bitCount(7) 3* Legal ops: ! ~ ^ | * Max ops: 40* Rating: 4*/
int bitCount(int x) {int m2 (0x558)|0x55;int m4 (0x338)|0x33;int m8 (0x0f8)|0x0f;m2 | (m216);m4 | (m416);m8 | (m816);x ~((x1)m2)1;x ((x2)m4)(xm4);x (x(x4))m8;x (x8);x (x16);return x0x3f;
}
/* * isLess - if x y then return 1, else return 0 * Example: isLess(4,5) 1.* Legal ops: ! ~ ^ | * Max ops: 24* Rating: 3*/
int isLess(int x, int y) {int ny ~y;return ((((xny1)(x^ny))|(xny))0x1f)1;
}
/* * isLessOrEqual - if x y then return 1, else return 0 * Example: isLessOrEqual(4,5) 1.* Legal ops: ! ~ ^ | * Max ops: 24* Rating: 3*/
int isLessOrEqual(int x, int y) {int ny ~y;return ((((((xny1)(x^ny))|(xny))0x1f))1)|!(x^y);
}
/** trueFiveEighths - multiplies by 5/8 rounding toward 0,* avoiding errors due to overflow* Examples: trueFiveEighths(11) 6* trueFiveEighths(-9) -5* trueFiveEighths(0x30000000) 0x1E000000 (no overflow)* Legal ops: ! ~ ^ | * Max ops: 25* Rating: 4*/
int trueFiveEighths(int x) {
int const eights x 3;
int const rem x 7;return eights (eights 2) (rem (rem 2) (x 31 7) 3);
}/*int s (x31)1;int c (s3)~s1;int h ((x(0xFF24))c)3;int l (x~(0xFF24));return (h2)h((((l2)l)c)3);*/
/** parityCheck - returns 1 if x contains an odd number of 1s* Examples: parityCheck(5) 0, parityCheck(7) 1* Legal ops: ! ~ ^ | * Max ops: 20* Rating: 4*/
int parityCheck(int x) {x ^ (x16);x ^ (x8);x ^ (x4);x ^ (x2);x ^ (x1);return x1;
}
/* * rempwr2 - Compute x%(2^n), for 0 n 30* Negative arguments should yield negative remainders* Examples: rempwr2(15,2) 3, rempwr2(-35,3) -3* Legal ops: ! ~ ^ | * Max ops: 20* Rating: 3*/
int rempwr2(int x, int n) {int s x31;x (xs)^s;x ((~0)(1n));return (x^s)~s1;
}
/* howManyBits - return the minimum number of bits required to represent x in* twos complement* Examples: howManyBits(12) 5* howManyBits(298) 10* howManyBits(-5) 4* howManyBits(0) 1* howManyBits(-1) 1* howManyBits(0x80000000) 32* Legal ops: ! ~ ^ | * Max ops: 90* Rating: 4*/
int howManyBits(int x) {int temp x ^ (x 1);int bit_16,bit_8,bit_4,bit_2,bit_1;bit_16 !!(temp 16) 4;temp temp bit_16;bit_8 !!(temp 8) 3;temp temp bit_8;bit_4 !!(temp 4) 2;temp temp bit_4;bit_2 !!(temp 2) 1;temp temp bit_2;bit_1 !!(temp 1);return 1 bit_1 bit_2 bit_4 bit_8 bit_16;
}
/** ilog2 - return floor(log base 2 of x), where x 0* Example: ilog2(16) 4* Legal ops: ! ~ ^ | * Max ops: 90* Rating: 4*/
int ilog2(int x) {int count 0;count (!!(x16)) 4;count count((!!(x(8 count)))3);count count((!!(x(4 count)))2);count count((!!(x(2 count)))1);count count((!!(x(1 count)))0);return count;
}
计算机是一种能够按照程序自动进行数据处理和运算的电子设备。计算机的发展可以分为四个阶段机械计算机、电子管计算机、晶体管计算机和集成电路计算机。
机械计算机是最早的计算机它们使用齿轮和滑动杆等机械装置进行计算。电子管计算机是第一代计算机它们使用电子管代替了机械装置大大提高了计算速度。晶体管计算机是第二代计算机它们使用晶体管代替了电子管使得计算机更加小型化和可靠化。集成电路计算机是第三代计算机它们使用集成电路代替了晶体管使得计算机更加高效和便携。
计算机的原理是基于二进制数制和逻辑电路。计算机中的所有数据都是以二进制形式存储和处理的逻辑电路则负责对这些数据进行运算和控制。计算机的核心是中央处理器(CPU)它包含算术逻辑单元(ALU)、控制单元(CU)和寄存器等组件负责执行指令和处理数据。
除了硬件计算机还需要软件来实现各种功能。软件可以分为系统软件和应用软件两类。系统软件包括操作系统、编译器和驱动程序等它们负责管理计算机的资源和提供基本的功能。应用软件则是为了满足用户的需求而开发的各种程序例如办公软件、游戏和浏览器等。
总之计算机是一种非常重要的电子设备它的发展历程经历了多个阶段从机械计算机到集成电路计算机每一代计算机都有着自己的特点和优势。计算机的原理基于二进制数制和逻辑电路它需要硬件和软件的配合才能实现各种功能。