亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? bits.c

?? LINUX下邏輯運算符的應用
?? C
字號:
/*  * ICS LAB1  * NOTES:NO TEAMWORK ALLOWED AND NO CHEATING!  * bits.c - Source file with your solutions to the Lab. *          This is the file you will hand in to your instructor. * * WARNING: Do not include the <stdio.h> header - it confuses the dlc * compiler. You can still use printf for debugging without including * <stdio.h>, although you might get a compiler warning. In general, * it's not good practice to ignore compiler warnings, but in this * case it's OK.   */#include "btest.h"#include <limits.h>/* * Instructions to Students: * * STEP 1: Fill in the following struct with your identifying info. */team_struct team ={   /* Replace with your full name */   "陸懿",   /* Replace with your student number*/   "0157085",};#if 0/* * STEP 2: Read the following instructions carefully. */You will provide your solution to the Data Lab byediting the collection of functions in this source file.CODING RULES:   Replace the "return" statement in each function with one  or more lines of C code that implements the function. Your code   must conform to the following style:   int Funct(arg1, arg2, ...) {      /* brief description of how your implementation works */      int var1 = Expr1;      ...      int varM = ExprM;      varJ = ExprJ;      ...      varN = ExprN;      return ExprR;  }  Each "Expr" is an expression using ONLY the following:  1. Integer constants 0 through 255 (0xFF), inclusive. You are      not allowed to use big constants such as 0xffffffff.  2. Function arguments and local variables (no global variables).  3. Unary integer operations ! ~  4. Binary integer operations & ^ | + << >>      Some of the problems restrict the set of allowed operators even further.  Each "Expr" may consist of multiple operators. You are not restricted to  one operator per line.  You are expressly forbidden to:  1. Use any control constructs such as if, do, while, for, switch, etc.  2. Define or use any macros.  3. Define any additional functions in this file.  4. Call any functions.  5. Use any other operations, such as &&, ||, -, or ?:  6. Use any form of casting.   You may assume that your machine:  1. Uses 2s complement, 32-bit representations of integers.  2. Performs right shifts arithmetically.  3. Has unpredictable behavior when shifting an integer by more     than the word size.EXAMPLES OF ACCEPTABLE CODING STYLE:  /*   * pow2plus1 - returns 2^x + 1, where 0 <= x <= 31   */  int pow2plus1(int x) {     /* exploit ability of shifts to compute powers of 2 */     return (1 << x) + 1;  }  /*   * pow2plus4 - returns 2^x + 4, where 0 <= x <= 31   */  int pow2plus4(int x) {     /* exploit ability of shifts to compute powers of 2 */     int result = (1 << x);     result += 4;     return result;  }NOTES:  1. Use the dlc (data lab checker) compiler (described in the handout) to      check the legality of your solutions.  2. Each function has a maximum number of operators (! ~ & ^ | + << >>)     that you are allowed to use for your implementation of the function.      The max operator count is checked by dlc. Note that '=' is not      counted; you may use as many of these as you want without penalty.  3. Use the btest test harness to check your functions for correctness.  4. The maximum number of ops for each function is given in the     header comment for each function. If there are any inconsistencies      between the maximum ops in the writeup and in this file, consider     this file the authoritative source.#endif/* * STEP 3: Modify the following functions according the coding rules. *  *   IMPORTANT. TO AVOID GRADING SURPRISES: *   1. Use the dlc compiler to check that your solutions conform *      to the coding rules. *   2. Use the btest test harness to check that your solutions produce  *      the correct answers. Watch out for corner cases around Tmin and Tmax. *////////////////////////////////////////////////////////////////////////////////// PART I ///////////////////////////////////////////////////////////////////////////////// Duplicate the behavior of the bit operation &.// Example: bitAnd(6, 5) = 4// Legal ops: ~ |// Max ops: 8// Rating: 1int bitAnd(int x, int y) {	return ~((~x)|(~y));}// Duplicate the behavior of the bit operation |.// Example: bitOr(6, 5) = 7// Legal ops: ~ &// Max ops: 8// Rating: 1int bitOr(int x, int y) {	return ~((~x)&(~y));}// Compares x to y, i.e. x==y. It should return 1 if the tested condition // holds and 0 otherwise.// Examples: isEqual(5,5) = 1, isEqual(4,5) = 0// Legal ops: ! ~ & ^ | + <<>> // Max ops: 5// Rating: 2int isEqual(int x, int y) {	return !(x^y);}// Does a logical right shift of x to the right by n.// Can assume that 1 <= n <= 31// Examples: logicalShift(0x87654321,4) = 0x08765432// Legal ops: ~ & ^ | + << >>// Max ops: 16// Rating: 3 int logicalShift(int x, int n) {	return (x>>n)&(~((1<<31)>>n<<1));}// Returns 1 if x contains an odd number of 1's, and 0 otherwise.// Examples: bitParity(5) = 0, bitParity(7) = 1// Legal ops: ! ~ & ^ | + <<>> // Max ops: 20// Rating: 4int bitParity(int x){	x=x^(x>>16);
	x=x^(x>>8);
	x=x^(x>>4);
	x=x^(x>>2);
	x=x^(x>>1);
	return x&1;}// Returns a mask that marks the position of the least significant 1 bit of x// with a 1. All other positions of the mask should be 0.// Example: leastBitPos(96) = 0x20// Legal ops: ! ~ & ^ | + << >>// Max ops: 30// Rating: 4 int leastBitPos(int x) {	return x&(~x+1);}// Returns a count of the number of 1's in the argument.// Examples: bitCount(5) = 2, bitCount(7) = 3// Legal ops: ! ~ & ^ | + << >>// Max ops: 40// Rating: 4int bitCount(int x) {	int m1=(0xFF<<8)+0xFF;//00000000 00000000 11111111 11111111
	int m2=(m1<<8)^m1;  //00000000 11111111 00000000 11111111
	int m3=(m2<<4)^m2;  //00001111 00001111 00001111 00001111
	int m4=(m3<<2)^m3;  //00110011 00110011 00110011 00110011
	int m5=(m4<<1)^m4;  //01010101 01010101 01010101 01010101 
	x=(x&m5)+((x>>1)&m5);
	x=(x&m4)+((x>>2)&m4);
	x=(x&m3)+((x>>4)&m3);
	x=(x&m2)+((x>>8)&m2);
	x=(x&m1)+((x>>16)&m1);
	return x;}// Compute !x without using ! operator.// Examples: bang(3) = 0, bang(0) = 1// Legal ops: ~ & ^ | + << >>// Max ops: 12// Rating: 4 int bang(int x) {	return ((x|(~x+1))>>31)+1;}///////////////////////////////////////////////////////////////////////////////// PART II ///////////////////////////////////////////////////////////////////////////////// Return maximum two's complement integer // Legal ops: ! ~ & ^ | + << >>// Max ops: 4// Rating: 1int tmax(void) {	return ~(1<<31);}// Compute -x without using - operator.// Example: negate(1) = -1.// Legal ops: ! ~ & ^ | + << >> // Max ops: 5// Rating: 2int negate(int x) {	return ~x+1;}// Determines whether argument y can be added to argument x without overflow.// Example: addOK(0x80000000,0x80000000) = 0, addOK(0x80000000,0x70000000) = 1 // Legal ops: ! ~ & ^ | + << >> // Max ops: 20// Rating: 3int addOK(int x, int y) {	int z=x+y;
	return !(((z^x)&(z^y))>>31);}// Check whether x is nonzero using the legal operators except !// Examples: isNonZero(3) = 1, isNonZero(0) = 0// Legal ops: ~ & ^ | + << >>// Max ops: 10// Rating: 4 int isNonZero(int x){	return (~((x|(~x+1))>>31))+1;}// Converts a number from sign-magnitude format to two抯 complement format. // That is, the high order bit of x is a sign bit s, while the remaining bits // denote a nonnegative magnitude m. The function should then return the // two抯 complement representation of (-1)^s*m.// Example: sm2tc(0x80000005) = -5.// Legal ops: ! ~ & ^ | + << >>// Max ops: 15// Rating: 4int sm2tc(int x) {	int s=x>>31;
	int m=(~(1<<31))&x;
	return (m^s)+(1&s);}// Compute absolute value of x. (Except it returns TMin for TMin)// Example: abs(-1) = 1.// Legal ops: ! ~ & ^ | + << >>// Max ops: 10// Rating: 4int abs(int x) {	int t=x>>31;	return (x^t)+(1&t);}// Adds two values and if the result (x+y) has a positive overflow it returns// the greatest possible positive value (instead of getting a negative result). // If the result has a negative overflow, then it should return the least // possible negative value.// Examples: satAdd(0x40000000,0x40000000) = 0x7fffffff//           satAdd(0x80000000,0xffffffff) = 0x80000000// Legal ops: ! ~ & ^ | + << >>// Max ops: 30// Rating: 4int satAdd(int x, int y) {	int z=x+y;
	int flow=((z^x)&(z^y))>>31;	return ((~flow)&z)|(flow&((1<<31)^(z>>31)));}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品你懂的| 国产日韩欧美高清| jizzjizzjizz欧美| 蜜桃视频一区二区| 亚洲精品欧美激情| 国产日产欧美一区二区三区| 欧美日韩高清不卡| av不卡在线观看| 精久久久久久久久久久| 亚洲成av人影院| 国产精品污网站| 日韩女优毛片在线| 欧美日韩大陆一区二区| 91玉足脚交白嫩脚丫在线播放| 毛片基地黄久久久久久天堂| 亚洲在线观看免费视频| 中文字幕在线视频一区| 国产亚洲一区二区在线观看| 欧美一区二区播放| 国产精品视频线看| 精品国产一区二区国模嫣然| 欧美日韩一级二级三级| 91热门视频在线观看| 成人激情文学综合网| 国产一二精品视频| 麻豆成人综合网| 日韩精品三区四区| 亚洲成av人在线观看| 一二三四社区欧美黄| 亚洲日本免费电影| 亚洲色图.com| 亚洲日本一区二区| 国产精品不卡在线| 国产精品久久久久久久久快鸭| 久久伊人中文字幕| 日韩精品一区二区三区老鸭窝| 欧美日韩高清影院| 欧美人成免费网站| 欧美人xxxx| 8x福利精品第一导航| 欧美日本视频在线| 欧美日韩一区久久| 6080yy午夜一二三区久久| 欧美四级电影在线观看| 欧美在线免费视屏| 在线观看国产91| 欧美无砖专区一中文字| 欧美私模裸体表演在线观看| 欧美日韩国产一区| 3d动漫精品啪啪1区2区免费| 欧美一二三四区在线| 日韩欧美国产午夜精品| 精品成人a区在线观看| 久久在线观看免费| 国产清纯美女被跳蛋高潮一区二区久久w| 久久精品亚洲乱码伦伦中文| 日本一区二区在线不卡| 国产精品国产三级国产a | 99re成人在线| 欧洲一区二区三区在线| 欧美另类高清zo欧美| 日韩欧美国产一区二区在线播放| 2023国产精华国产精品| 欧美国产日韩a欧美在线观看| 中文字幕一区二区三区四区不卡| 亚洲女同一区二区| 丝袜亚洲另类欧美| 国内精品伊人久久久久av一坑| 国产一级精品在线| 91丨porny丨户外露出| 欧美色综合天天久久综合精品| 91.麻豆视频| 久久精品男人天堂av| 一区二区在线观看视频| 久久国产夜色精品鲁鲁99| 成人免费福利片| 欧美精品1区2区3区| 亚洲日本一区二区| 国产福利一区二区| 色哟哟一区二区在线观看| 制服丝袜中文字幕一区| 国产人伦精品一区二区| 亚洲综合色在线| 国产呦萝稀缺另类资源| 色欧美日韩亚洲| 久久亚洲精品国产精品紫薇| 成人av免费在线| 欧美日韩在线观看一区二区 | 久久久午夜精品| 亚洲视频1区2区| 美美哒免费高清在线观看视频一区二区 | 欧美一区二区精美| 国产日韩欧美精品电影三级在线| 亚洲国产日韩一区二区| 国产麻豆精品在线观看| 欧美日韩免费一区二区三区| 国产日韩v精品一区二区| 亚洲18女电影在线观看| 成人白浆超碰人人人人| 欧美精品精品一区| 亚洲视频狠狠干| 国产福利一区二区三区视频| 91超碰这里只有精品国产| 亚洲日本丝袜连裤袜办公室| 国产剧情在线观看一区二区| 91精品国产综合久久久蜜臀粉嫩 | 一区二区三区毛片| 国产福利一区二区| 日韩一区二区免费在线观看| 亚洲三级在线免费| 成人午夜私人影院| 久久久亚洲国产美女国产盗摄 | 欧美丰满高潮xxxx喷水动漫| 国产精品久久久久天堂| 狠狠色丁香久久婷婷综合_中 | 99国产精品久久久久| 精品日韩欧美在线| 婷婷成人综合网| 欧美系列亚洲系列| 亚洲色欲色欲www在线观看| 国产精品资源站在线| 日韩一区二区三区电影在线观看| 亚洲成av人综合在线观看| 色国产综合视频| 亚洲精品免费看| 94-欧美-setu| 亚洲天堂2014| 99国产精品一区| 亚洲欧洲国产日韩| 成人app下载| 亚洲国产高清不卡| 成人综合日日夜夜| 国产女主播在线一区二区| 国产黄色精品网站| 久久久精品欧美丰满| 国产在线精品一区二区| 精品国产髙清在线看国产毛片| 日韩成人伦理电影在线观看| 这里只有精品电影| 蜜桃视频一区二区三区| 日韩精品一区二区三区在线 | 免费看欧美女人艹b| 欧美另类久久久品| 日韩1区2区日韩1区2区| 在线播放国产精品二区一二区四区 | 91丨porny丨中文| 日韩一区在线看| 欧美影视一区二区三区| 亚洲成人综合视频| 日韩欧美久久久| 国产精品夜夜爽| 国产精品嫩草影院av蜜臀| 91一区一区三区| 亚洲国产成人va在线观看天堂| 欧美日韩国产电影| 乱一区二区av| 中文字幕av不卡| 欧美午夜视频网站| 美国欧美日韩国产在线播放| 久久免费精品国产久精品久久久久 | 一区二区三区在线观看国产| 欧美丝袜丝交足nylons图片| 三级欧美在线一区| 26uuuu精品一区二区| 成人av免费观看| 亚洲国产成人tv| 久久综合中文字幕| 99视频一区二区| 婷婷六月综合亚洲| 国产色产综合色产在线视频| 色婷婷久久久综合中文字幕| 青青草原综合久久大伊人精品优势| 欧美成人女星排行榜| 成人毛片视频在线观看| 夜夜精品视频一区二区 | 91精品国产综合久久精品app | 中文字幕高清不卡| 欧美日韩成人一区二区| 国产精品自在欧美一区| 一区二区三区四区激情 | 亚洲一区二区三区四区五区黄| 91精品黄色片免费大全| 成人av电影免费观看| 奇米精品一区二区三区在线观看| 久久久久久日产精品| 欧洲一区二区三区在线| 国产乱人伦精品一区二区在线观看| 亚洲欧美日韩在线不卡| 日韩欧美国产系列| 色婷婷综合中文久久一本| 激情五月婷婷综合| 一区二区高清视频在线观看| 精品国产免费久久| 在线一区二区三区四区五区| 国产精品亚洲视频| 奇米影视7777精品一区二区| 亚洲天天做日日做天天谢日日欢| 日韩免费电影网站| 欧美色综合网站| 99riav一区二区三区|