Skip to content

Instantly share code, notes, and snippets.

View Dockerfile
FROM centos:7
RUN yum install -y libaio-devel fio && \
yum clean all && \
rm -rf /var/cache/yum
@YaoC
YaoC / grades.py
Created Jul 4, 2017
分数到成绩的对应
View grades.py
import bisect
def grade(score, breakpoints=[60, 70, 80, 90], grades='FDCBA'):
i = bisect.bisect(breakpoints, score)
return grades[i]
if __name__ == '__main__':
grades = [grade(score) for score in [33, 99, 77, 70, 89, 90, 100]]
@YaoC
YaoC / rcu_demo.c
Created May 14, 2017
Linux内核第四次作业
View rcu_demo.c
/**
* @Author: ChengYao
* @Created time: 2017年5月14日 下午5:08
* @Email: chengyao09@hotmail.com
* @Description: Linux内核第四次作业
*
*/
/**
* [thread_writer description]
@YaoC
YaoC / 0_reuse_code.js
Created Mar 2, 2017
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View main.cpp
#include <iostream>
using namespace std;
int main(int argc, char *argv[]) {
cout<<"你输入了"<<argc-1<<"个参数"<<endl;
if(argc==1)
return 0;
if(argc==2)
cout << "读入图片" << argv[1] << endl;
if(argc==3) {
cout << "指定尺寸错误!\n";
View array_map.hpp
template<class KEY,class T>
T& ArrayMap<KEY,T>::operator [] (const KEY& key) {
int i = index_of(key);
if (i != -1)
return map[i].second;
this->ensure_length(used+1);
map[used++] = Entry(key,T());
++mod_count;
return map[used-1].second;
View array_map.hpp
template<class KEY,class T>
const T& ArrayMap<KEY,T>::operator [] (const KEY& key) const {
int i = index_of(key);
if (i != -1)
return map[i].second;
std::ostringstream answer;
answer << "ArrayMap::operator []: key(" << key << ") not in Map";
throw KeyError(answer.str());
}
View reachable.cpp
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include "ics46goody.hpp"
#include "array_queue.hpp"
#include "array_priority_queue.hpp"
#include "array_set.hpp"
#include "array_map.hpp"
View Main.java
/**
* Created by chengyao on 2017/1/12.
*/
public class Main {
public static void main(String[] args) {
Rectangle rect = new Rectangle(1, 3, 2.5, 4);
System.out.println("长方形的位置:("+rect.getX()+","+rect.getY()+"),面积为:"+rect.getArea());
rect = new Rectangle(3, 5, 4, 8);
System.out.println("现在长方形的位置:("+rect.getX()+","+rect.getY()+"),面积为:"+rect.getArea());
}
View stringToList.cpp
#include <iostream>
using namespace std;
struct ListNode{
char info;
ListNode* next;
ListNode(char newinfo, ListNode* newNext) {
info = newinfo;
next = newNext;
}