This file contains hidden or 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
#!/bin/bash | |
# Usage: the first parameter should be the exported QQ message file | |
echo -e "Hour\tMyCnt\tMyLen\tMyAvglen\tHerCnt\tHerLen\tHer Avglen"; cat $1 | awk '/2014-/ { if($3=="boj") { split($2,time,":"); hour=time[1]; getline; me_len[hour]+=length($0); me_num[hour]++ } else { split($2,time,":"); hour=time[1]; getline; her_len[hour]+=length($0); her_num[hour]++ } } END {for(key in me_num) printf("%s\t%d\t%d\t%lf\t%d\t%d\t%lf\t\n", key, me_num[key], me_len[key], me_len[key] * 1.0 / me_num[key], her_num[key], her_len[key], her_len[key] * 1.0 / her_num[key] ) }' | sort -n | |
echo -e "Date\tMyCnt\tMyLen\tMyAvglen\tHerCnt\tHerLen\tHer Avglen"; cat $1 | awk '/2014-/ { if($3=="boj") { split($2,time,":"); hour=time[1]; getline; me_len[hour]+=length($0); me_num[hour]++ } else { split($2,time,":"); hour=time[1]; getline; her_len[hour]+=length($0); her_num[hour]++ } } END {for(key in me_num) printf("%s\t%d\t%d\t%lf\t%d\t%d\t%lf\t\n", key, me_num[key], me_len[key], me_len[key] * 1.0 / me_num[key], her_num[key], her_len[k |
This file contains hidden or 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<math.h> | |
#define MAX 1000 | |
#define MAX_ITEMS 100 | |
int main() { | |
int i, j; | |
int n = 0, w[MAX_ITEMS+1] = {0}; | |
int s[MAX_ITEMS+1][MAX+1] = {1}; | |
float weight; | |
while (scanf("%f", &weight) != EOF) { |
This file contains hidden or 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<math.h> | |
#define MAX 1000 | |
#define MAX_ITEMS 100 | |
int main() { | |
int i, j; | |
int n = 0, w[MAX_ITEMS+1] = {0}; | |
int s[MAX+1] = {1}; | |
float weight; | |
while (scanf("%f", &weight) != EOF) { |
This file contains hidden or 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
/* File format: | |
* Number of couples | record for couple 1 | record for couple 2... | |
* int | No. | boy name | girl name | next pointer | ... | |
* | int | string | string | pointer | | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> |
This file contains hidden or 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 SimpleHTTPServer | |
import SocketServer | |
import urlparse | |
PORT = 80 | |
class ServerHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): | |
def do_GET(self): | |
try: | |
query = urlparse.parse_qs(urlparse.urlparse(self.path).query) |
This file contains hidden or 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> | |
struct cal { | |
int hour, minute, second, day, month, year; | |
}; | |
struct cal convert(struct cal in) { | |
struct cal out; | |
in.year -= 2000; | |
int past_years = in.month >= 3 ? in.year + 1 : in.year; | |
int days = in.year * 365 + (past_years + 3) / 4 - (past_years + 99) / 100 + (past_years + 399) / 400; |
This file contains hidden or 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> | |
#define HASH_SIZE 300007 | |
#define LINE_LEN 32 | |
char dict[HASH_SIZE][LINE_LEN] = {0}; | |
static unsigned int BKDRhash(char* key) { | |
unsigned int seed = 131; // 31 131 1313 13131 131313 etc.. | |
unsigned int hash = 0; |
This file contains hidden or 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> | |
int main() { | |
int num = 0; | |
int i, j, k; | |
char a[1001][22] = {0}; | |
int idx[1001], tmpidx; | |
char tmp[22] = {0}; | |
while (scanf("%s", a[num++]) != EOF); |
This file contains hidden or 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
using namespace std; | |
#include <iostream> | |
class Complex { | |
private: | |
double real; | |
double im; | |
public: | |
Complex(double real, double im) { |
This file contains hidden or 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
using namespace std; | |
#include <iostream> | |
int getPower(int x, int n) { | |
if (x == 0) | |
return 0; | |
if (n == 0) | |
return 1; | |
else if (n > 0) | |
return getPower(x, n-1) * x; | |
else // n < 0 |