Tips

  1. 使用反向代理时,git相关命令会出问题
  2. 实验前,创建新分支pa号,在其中做修改,完成以后合并pa到master中,并转回master分支

模板

# PA
## notification
-
## difficulties
1.
## summary

PA0

notification

  • 全程使用git
  • git commit --allow-empty可以使git空(无更改的)提交
阅读全文 »

0.0 PTA实录

0.1.1 最大子列和plus

  • 如何利用语句先后顺序记录上一条信息pre_start_tag
void sum_max_sequence(void)
{
long long int this_sum, max_sum;
int start_tag, end_tag, pre_start_tag, neg_tag;

start_tag = pre_start_tag = end_tag = 0;
this_sum = max_sum = 0;
neg_tag = 1;

for (int i = 0; i < num; i++)
{
if (list[i] >= 0) {
neg_tag = 0;
}
this_sum += list[i];
if (this_sum > max_sum)
{
max_sum = this_sum;
end_tag = i;
pre_start_tag = start_tag; // 我没有想到的代码!
}
if (this_sum < 0)
{
this_sum = 0;
start_tag = i+1;
}
}


if(neg_tag) // 输出0,第一个和最后一个数
printf("%lld %d %d\n", max_sum, list[0], list[num-1]);
else if (max_sum == 0)
{
printf("0 0 0\n");
}

else
printf("%lld %d %d\n", max_sum, list[pre_start_tag], list[end_tag]);
}
阅读全文 »

基本知识

特殊字符

*:匹配前面的字符0+次
+:匹配前面的字符1+次
?:匹配前面的字符0/1次
[a-z_]:匹配中括号内字符1次,示例是匹配小写字母或下划线

定位符

^:表示开头处
$:表示结尾处
\b:匹配单词间的空格处

特殊序列

\d:匹配数字
\w:匹配字母、数字、下划线
\s:匹配不可见字符
\D:匹配非数字
\W:匹配非字母、数字、下划线
\S:匹配非空白字符

举例

  • “hel?o”:可以匹配heo, helo(0次或1次)
  • “hel+o”:可以匹配helo, hello(1次以上)
  • “hel*o”:可以匹配heo, helo, hello(0次以上)
  • r"+\-*/":匹配加减乘除符号,r表示不转义

“When in doubt go to the library.” – J.K.Rowling

Catalog

Article1: What Are You Going to Do With That?

What Are You Going to Do With That?

William Deresiewicz(《国家》杂志撰稿人和《新共和》杂志编辑)在斯坦福大学的演讲

The question my title poses, of course, is the one that is classically aimed at humanities majors. What practical value could there possibly be in studying literature or art or philosophy? So you must be wondering why I’m bothering to raise it here, at Stanford, this renowned citadel of science and technology. What doubt can there be that the world will offer you many opportunities to use your degree?

(学习文学、艺术或哲学能有什么用呢?所以你肯定纳闷,我为什么在在以科技堡垒而闻名的斯坦福提出这个问题呢?在大学学位给人带来众多机会的问题上还有什么可怀疑的吗?)

But that’s not the question I’m asking. By “do” I don’t mean a job, and by “that” I don’t mean your major. We are more than our jobs, and education is more than a major. Education is more than college, more even than the totality of your formal schooling, from kindergarten through graduate school. By “What are you going to do,” I mean, what kind of life are you going to lead? And by “that,” I mean everything in your training, formal and informal, that has brought you to be sitting here today, and everything you’re going to be doing for the rest of the time that you’re in school.

(但那不是我提出的问题。这里的“做”并不是指工作,“那”并不是指你的专业。我们不仅仅是要个工作,教育不仅仅是学一门专业。教育也不仅仅是上大学,甚至也不仅是从幼儿园到研究生院的正规学校教育。我说的“你要做什么”的意思是你要过什么样的生活?我所说的“那”指的是你得到的正规或非正规的任何训练, 那些把你送到这里来的东西,你在学校的剩余时间里将要做的任何事。)

阅读全文 »

技术博主

  • 多看开发者大会!
  1. ThePrimeTime
  2. CodeAesthetic
  3. Molly Rocket

What’s so special about 2147483648?

by Sandra Henry-Stocker, Unix Dweeb, from NetWorkWorld 945870
tags: Data Center, Linux, Open Source
难度:EASY

First of all, it’s a power of 2. That’s undoubtedly not the most obvious thing unless you’re some kind of mathematical genius. And, to be exact, it’s 2^31. That’s significant — as you’ll see in a minute.

In binary, 2147483647 is 01111111111111111111111111111111 and it’s the biggest positive number that will fit in 32 bits when using the “two’s complement” notation (补码) — the way of representing numbers that allows for negative values. If we could use that leftmost (high order) bit, the largest possible number would be twice as large since every extra bit doubles the range of numbers that a binary number can represent.

And 2147483648 just happens to be the number you’d get if you multiplied 256 * 256 * 256 * 256 and then divided the result by 2. Not excited yet? Give me a moment.

阅读全文 »

标准写法

  • 编译hello.c
hello:hello.c
gcc hello.c -o hello # 注意开头的tab, 而不是空格

.PHONY: clean
# 用于指示"clean是一个伪目标", 伪目标相应的命令序列总是会被执行.

clean:
rm hello # 注意开头的tab, 而不是空格

生成目标文件名:依赖文件列表
用于生成目标文件的命令序列 # 注意开头的tab, 而不是空格
  • 更有效率的写法
CC=gcc
CFLAGS=-I.

hellomake: hellomake.o hellofunc.o
$(CC) -o hellomake hellomake.o hellofunc.o
  • 全部编译
SOURCE = $(wildcard *.c)  
TARGETS = $(patsubst %.c, %, $(SOURCE))

CC = gcc
CFLAGS = -Wall -g

all: $(TARGETS)

%: %.c
$(CC) $< $(CFLAGS) -o $@

.PHONY:clean all

clean:
rm -f $(TARGETS)

Makefile文件的格式

[廖雪峰](http://ruanyifeng.com/blog/2015/02/make.html)

Makefile文件由一系列规则(rules)构成。每条规则的形式如下。

<target>: <prerequisites> 
[tab] <commands>

上面第一行冒号前面的部分,叫做"目标"(target),冒号后面的部分叫做"前置条件"(prerequisites);第二行必须由一个tab键起首,后面跟着"命令"(commands)。

  • 键入make -nB, 它会让make程序以"只输出命令但不执行"的方式强制构建目标。

文件名匹配

%.o: %.c # 所有.o/.c结尾的文件

变量

txt = Hello World
test:
@echo $(txt) # 变量放在$()中,@表示不打印直接执行

信息系统架构

  • 信息化系统:前台 + 后台 + 数据库
  • B/S 模式
  • 前端 -> Server[Apache->PHP(TP6.0)] -> SQL DataBase
  • 运行逻辑:
    • Client发送require请求(http协议),包含header(length、refer信息)、body(数据)
    • Apache接受请求,给PHP做处理
    • PHP读取、处理数据;判断数据是否损毁、是否需要退回
    • 数据更新到前端,并返回结果(success/fail)
阅读全文 »

第一阶段 程序的表示、转换与链接

参考MOOC:NJU-1001625001

1.0 计算机系统概述

1.3 程序开发和执行过程

  1. hello.c程序用ascii文本表示
  2. 首先.c文件预处理为.i文件(把预处理指令翻译过来),然后.i文件编译成.s文件(汇编程序文本),接着.s文件汇编成.o文件(二进制),与printf等函数的.o文件共同连接成可执行文件(二进制)
  3. 高级语言编写程序所需环境:(1)语言处理程序; (2)语言处理系统; (3)语言运行时的系统; (4)操作系统内核; (5)操作系统; (6)指令集体系结构; (7)人机接口

1.4 计算机系统层次结构

  • 过程式语言:如何做; 非过程化语言:做什么;语言发展是不断抽象的过程
  • 应用->算法->语言->操作系统->(软件)ISA指令集(硬件)->微体系、功能部件、电路和器件
    非预期结果是硬件层次造成的。上层是下层的抽象,下层是上层的实现,底层为上层提供支撑环境
  • 题目:由机器语言编程的早期计算机系统中,没有ISA这一层次(F);一直都有ISA,因此ISA是计算机体系层次中最重要的层次
    ISA, Instruction Set Architecture(结构)规定了如何使用硬件,是可以执行的指令的集合,包括指令格式、操作种类及操作数的类型的规定…
    没有ISA,软件无法使用计算机硬件,一台计算机就不能成为“通用”计算机
  • 计算机组成必须能够实现ISA规定的功能;同一种ISA可以由不同的计算机(硬件)组成,如乘法指令用ALU或乘法器都可以实现
  • 题目:有没有乘法指令是ISA考虑的问题,如何实现乘法指令是微体系结构考虑的问题

1.5 计算机系统基础学习目标

  • 编写高效程序必须了解计算机底层结构
  • 必须掌握并行程序设计技术和工具
  • 课程目标:理解计算机如何生成和运行可执行文件
  • 涉及层次:C语言设计层,ISA和汇编层,微体系结构和硬件层
  • 第一部分 程序表示与转换;第二部分 执行控制流
阅读全文 »

1.0 Bar 柱状图

from pyecharts.charts import Bar

bar = Bar()
bar.add_xaxis(["衬衣", "羊毛衫", "西装", "裤子", "鞋子", "袜子"])
bar.add_yaxis("商家", [5, 20, 40, 10, 70, 90])
# 相当于
bar = (
Bar()
.add_xaxis(["衬衣", "羊毛衫", "西装", "裤子", "鞋子", "袜子"])
.add_yaxis("商家", [5, 20, 40, 10, 70, 90])
.add_yaxis("商家B", [15, 6, 45, 20, 35, 66]) # 支持两个柱子同时生成
.set_global_opts(title_opts=opts.TitleOpts(title="主标题", subtitle="副标题")) # 生成标题
)


bar.render("bar.html") # 渲染为 bar.html,默认是 render.html
  • 效果
Awesome-pyecharts
阅读全文 »

  • 复杂度分析:数据结构和算法的评价维度与方法。时间复杂度、空间复杂度的推算方法、常见类型、示例等。
  • 数据结构:基本数据类型,数据结构的分类方法。数组、链表、栈、队列、哈希表、树、堆、图等数据结构的定义、优缺点、常用操作、常见类型、典型应用、实现方法等。
  • 算法:搜索、排序、分治、回溯、动态规划、贪心等算法的定义、优缺点、效率、应用场景、解题步骤、示例题目等。
阅读全文 »
0%