C语言高质量练习题
1.数据存储
7 4 1 -2
-2:
1000 0000 0000 0000 0000 0000 0000 0010
1111 1111 1111 1111 1111 1111 1111 1101
1111 1111 1111 1111 1111 1111 1111 1110
1111 1110 == 2^8-1-1==254
7 4 1 254 251 248… … 2 -1
-1:
1000 0000 0000 0000 0000 0000 0000 0001
1111 1111 1111 1111 1111 1111 1111 1110
1111 1111 1111 1111 1111 1111 1111 1111
1111 1111==2^8-1=255
*7 4 1 254 251 248… … 2 255 252 249… … * 0
254/3= =84…2 总共84+1次
255/3= =85…0 总共85+1-1次 (最后一个0不算)
j:3+85+85==173
拓展:查数字
5循环减2
5/2==2…1
余1说明最后一次得到的是1
5 3 1
总共q+1次
2.程序阅读
1abcdef2df
1AbCdEf2dF
3.网页搜索自动生成字符串
#include <stdio.h>
#include <string.h>
void replace(char* s, int len)
{int c = 0, Len, e1, e2;char* p = s;//数空格while (*p){if (*p == ' ')c++;p++;}Len = len + 2 * c;e1 = len - 1;e2 = Len - 1;while (e1 != e2){if (s[e1] != ' ')s[e2--] = s[e1--];else{s[e2--] = '0';s[e2--] = '2';s[e2--] = '%';e1--;}}
}
int main()
{char s[50] = "We Are Happy.";printf("%s\\n", s);int len = strlen(s);replace(s, len);printf("%s", s);return 0;
}