程序设计实验一(位运算)

 

上程序设计课(csapp)接触位运算感觉蛮有意思的,虽然老师讲得好快啊。。。。这大概也是我第一次用位运算来实现功能,最后还把离散的数理逻辑用上了,哎,也真心佩服自己了,把代码贴出来给自己留个纪念吧,不然放文件夹里估计也生

附带几个位运算有关的网站:

 

http://www.cppblog.com/aqazero/archive/2012/11/10/8284.html(c语言优先级列表,这表太好了,

做题目的时候忘记的不懂都来翻一下,感觉慢慢都要记住了。。额)

 

http://www.cnblogs.com/graphics/archive/2010/06/21/1752421.h(只能说,没看到这个之前,,,,

不,看到这个之后,瞬间惊呆了,算法的魅力吧。)

  http://blog.sina.com.cn/s/blog_66ad7bba0100hf9k.html(一些有意思的位运算技巧)
  /*
  * CS:APP Data Lab
  *
  * 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 =
  {
  /* Team name: Replace with either:
  Your login ID if working as a one person team
  or, ID1+ID2 where ID1 is the login ID of the first team member
  and ID2 is the login ID of the second team member */
  "SA15226245+SA15226240",
  /* Student name 1: Replace with the full name of first team member */
  "杨宗明",
  /* Login ID 1: Replace with the login ID of first team member */
  "SA15226***",
   
  /* The following should only be changed if there are two team members */
  /* Student name 2: Full name of the second team member */
  "周子翔",
  /* Login ID 2: Login ID of the second team member */
  "SA15226***"
  };
   
  #if 0
  /*
  * STEP 2: Read the following instructions carefully.
  */
   
  You will provide your solution to the Data Lab by
  editing 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
 
  • 2
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值