Skip to content

Instantly share code, notes, and snippets.

View henrybear327's full-sized avatar

Chun-Hung Tseng henrybear327

View GitHub Profile
@henrybear327
henrybear327 / Midterm-homework.c
Last active May 9, 2017 11:52
Midterm-homework.c
#include <stdio.h>
#include <string.h>
#define BUFFER_SIZE 10000
int isValid(char c)
{
return ('A' <= c && c <= 'Z') || ('0' <= c && c <= '9');
}
@henrybear327
henrybear327 / ITSA 2017 Apr 5.cpp
Created April 12, 2017 16:16
ITSA 2017 Apr 5.cpp
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
int ncase;
scanf("%d", &ncase);
@henrybear327
henrybear327 / find and replace.c
Last active May 9, 2017 11:52
find and replace.c
/*405415039 ������*/
#include <memory.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
FILE *HW = fopen("input.txt", "r");
FILE *hw = fopen("output.txt", "w");
@henrybear327
henrybear327 / class.cpp
Created March 28, 2017 06:23
class.cpp
#include <iostream>
using namespace std;
class Test
{
public:
Test();
Test(int num);
private:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define N 10000
double dist(int a, int b)
{
@henrybear327
henrybear327 / 1_query_timestamp.js
Created March 23, 2017 14:06 — forked from katowulf/1_query_timestamp.js
Get only new items from Firebase
// assumes you add a timestamp field to each record (see Firebase.ServerValue.TIMESTAMP)
// pros: fast and done server-side (less bandwidth, faster response), simple
// cons: a few bytes on each record for the timestamp
var ref = new Firebase(...);
ref.orderByChild('timestamp').startAt(Date.now()).on('child_added', function(snapshot) {
console.log('new record', snap.key());
});
@henrybear327
henrybear327 / struct pointer.cpp
Last active March 16, 2017 13:33
struct pointer.cpp
#include <stdio.h>
struct data {
int a;
};
typedef struct data2 {
int aa;
} hello; //以後不用打struct data2,直接叫他hello就好了!!
@henrybear327
henrybear327 / UVA108.cpp
Last active March 16, 2017 05:31
UVA108.cpp
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
while(scanf("%d", &n) == 1) {
// read input
int data[n + 1][n + 1];

Tested on Ubuntu 16.04.2

  • wget http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-6.3.0/gcc-6.3.0.tar.gz

  • tar xzf gcc-6.3.0.tar.gz # decompress

  • cd gcc-6.3.0

  • ./contrib/download_prerequisites # recent compiler binaries have this handy script :)

  • cd ..

  • mkdir gcc63

/*
使用前调用init静态建树,然后模仿query进行类Binary Search Tree式的访问即可
Obj是点的类型,如果追求效率或者在点上除了坐标还有其它信息,可以自己写一个Obj类,然后重载[]运算符
*/
namespace KDTree {
int K;
typedef vector <int> Obj;
template <int T> bool cmpT(const Obj &a, const Obj &b) { return a[T] < b[T]; }
bool (*cmp[])(const Obj &, const Obj &) = {cmpT <0>, cmpT <1>, cmpT <2>}; //填到所需要的最大维度数目为止,这里表示的是最大3维
struct Filter {