This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def triangles(max): | |
n = 3 | |
my_list = [1] | |
if max > 1: | |
yield my_list | |
if max > 2: | |
my_list = [1, 1] | |
yield my_list | |
while n <= max: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 配置信息的token随意填,和这里的一样就行 | |
var PORT = 8080; //监听8080端口号 | |
var http = require('http'); | |
var qs = require('querystring'); | |
var TOKEN = 'beiweiqiang'; //必须与测试号所填写的Token相同 | |
function checkSignature(params, token) { | |
var key = [token, params.timestamp, params.nonce] | |
.sort() | |
.join(''); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; (function (window, $) { | |
'use strict'; | |
var $scrollTo; | |
var timer = null; | |
var scrollTop = 0; | |
window.onscroll = function () { | |
scrollTop = document.documentElement.scrollTop || document.body.scrollTop; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int get_msb(int w); | |
int main() { | |
int x = 2147483647; | |
printf("%zd %d\n", sizeof(int), get_msb(x)); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
/* | |
* 所有位都为 1 时返回 1, 其他条件下产生 0 | |
* */ | |
int get_result(int x); | |
int main() { | |
printf("%d \n", get_result(1)); | |
printf("%d \n", get_result(-1)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
/* | |
* 所有位都为 0 时返回 1, 其他条件下产生 0 | |
* */ | |
int get_result(int x); | |
int main() { | |
printf("%d \n", get_result(1)); | |
printf("%d \n", get_result(-1)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
/* | |
* 最低有效字节中的位都为 1, 则返回 1, 其他条件下产生 0 | |
* */ | |
int get_result(int x); | |
int main() { | |
printf("%d \n", get_result(1)); | |
printf("%d \n", get_result(-1)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
/* | |
* 最高有效字节中的位都为 0, 则返回 1, 其他条件下产生 0 | |
* */ | |
int get_result(int x); | |
int main() { | |
printf("%d \n", get_result(1)); | |
printf("%d \n", get_result(-1)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
/* | |
* CSAPP exercise 2.62 | |
* */ | |
/* | |
* 如果机器是对 int 类型数使用算术右移, 返回 1, 其他返回 0 | |
* */ | |
int int_shifts_are_arithmetic(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
/* | |
* CSAPP exercise 2.63 | |
* */ | |
/* | |
* 用算术右移, 完成逻辑右移 | |
* */ | |
unsigned srl(unsigned x, int k); |
OlderNewer