[2017.11.16]作业11(c)

来源:互联网 发布:富士人机界面编程软件 编辑:程序博客网 时间:2024/06/03 21:09

1、int intvert(unsigned int x,int p,int n)实现对x的进行转换,p为起始转化位, n为需要转换的长度,假设起始点在右边.
如x=0b0001 0001,p=4,n=3转换后x=0b0110 0001。

unsigned int temp = 0;  unsigned int a = 1;  int i;  for (i=0; i<n; ++i) {      temp |= a;        a = a << 1;  }temp = temp << p;x ^= temp;    int main()  {      return 0;  }  

2、已知WAV文件格式如下表,打开一个WAV文件,以适当的数据结构组织WAV文件头并解析怎样获取WAV格式的各项信息。
这里写图片描述

不会

3、下面这段代码是把中英文混合字符串(汉字用两个字节表示,特点是第一个字节的最高位是1)中的大写字母转化为小写字母,找出其中的bug。
for (char *piterator=sz_word; *piterator!=0; piterator++)
{
if (*piterator & 0x80 != 0)
{
piterator++;
}
else if (*piterator>=’A’ && *piterator<=’Z’)
piterator += 32;
}

if ( *p & 0x80 != 0)改为if (((*p) & 0x80) != 0) if (*p & 0x80 == 0 && *p >= 'A' && *p <= 'Z')改为if ( (( (*p) & 0x80) == 0) && ((*p) >= 'A') && ((*p) <= 'Z')) 
原创粉丝点击