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.64 | |
* */ | |
/* | |
* 当所有奇数位为 1, 返回 1 | |
* 假设 w 为 32 | |
* */ |
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
/* | |
* CS:APP Data Lab | |
* | |
* <Please put your name and userid here> | |
* bei wei qiang | |
* 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 |
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> | |
#include <stdlib.h> | |
#include <time.h> | |
// 定义方格边大小 | |
#define SIZE 4 | |
#define INIT_RAND_COUNT 2 | |
// 表示位置 |
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
# 用于添加, 浏览, 删除 联系人的电话 | |
import pickle | |
import os | |
data = [] | |
target = 'backup' | |
file_name = 'backup_data.data' | |
path = os.path.join(target, file_name) | |
if os.path.exists(path): |
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
# Fibonacci Sequence | |
# Enter a number and have the program generate the Fibonacci sequence | |
# to that number or to the Nth number. | |
import sys | |
sys.setrecursionlimit(10000) | |
def fibonacci(n): |
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
# Prime Factorization - | |
# Have the user enter a number and | |
# find all Prime Factors (if there are any) and display them. | |
# primer factors: | |
# table https://en.wikipedia.org/wiki/Table_of_prime_factors | |
def prime_factor(n): | |
if n == 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
# Next Prime Number | |
# Have the program find prime numbers until the user chooses to stop asking for the next one. | |
# 找到下一个质数 | |
prime_number = [2] | |
i = 0 | |
def find_next_prime(): | |
global i |
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
# Fast Exponentiation | |
# Ask the user to enter 2 integers a and b and output a^b (i.e. pow(a,b)) in O(lg n) time complexity. | |
def my_pow(a, b): | |
if b == 0: return 1 | |
temp = my_pow(a, b // 2) | |
if b % 2 == 0: | |
return temp * temp | |
else: |
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
# Sorting | |
# Implement two types of sorting algorithms: | |
# Merge sort and bubble sort. | |
import math | |
from random import randint | |
def merge_arr(arr1, arr2): | |
""" |
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
const http = require('http'); | |
const crypto = require('crypto'); | |
const realm = 'user'; | |
const ACCOUNT = { | |
'username': 'psw' | |
}; | |
class Nonce { | |
constructor() { |