ソースコード

前回と同じくソースコードを公開します. ツッコミなどをコメントに書いていただけたら感激ですd(・・ /*! * \file main.cpp */ #include <iostream> using namespace std; #include "./twitterStreaming.hpp" #define CR 13 #define LF 10 void *myrealloc(void *ptr, s</iostream>…

Tweet の情報をごっそり集める

「user」だけが入れ子になっていたので,object を見つけたら再帰的に持ってきて,全て map に入れちゃいました. 全部を辞書順に並べちゃうのは json としてどうなんでしょうね? json についても要勉強です.

キーワードや ID を指定して Tweet を持ってくる

これは取りに行く json を変えるだけですね. 複数のキーワードや人を追いかけるときはカンマでつなげればいいらしいです. 詳しくは wiki で確認できます. 2行目の ID は僕の ID です. RSS フィードの URL から確認したのですが,もっとスマートな方法が…

キーワードや ID で追ったり,Tweet の情報をごっそり集めたりしてみる

きっかけやお世話になった方々についてはこちら「Twitter の Streaming API を C/C++ でいじってみた(1)」へどうぞ.

とりあえず statuses/sample を持ってくる

「pingpong003ワークショップ@公立はこだて未来大学」に参加したのがきっかけで,「#ppfun」というハッシュタグを付けたつぶやきを流すアプリケーションをひそかに作っています. そこで見つけたのがこれ,Twitter の Streaming APIをいじってみました. キ…

Problem33

/* * \file problem033.cpp * \brief Project Euler - Problem33 * * \author Takushi Homma (b1006018@fun.ac.jp) */ #include <iostream> #include <vector> #include <cmath> using namespace std; #define LMT 100 bool isNontrivial(int e, int d, int *pe, int *pd) { if (d%10 </cmath></vector></iostream>…

Problem32

/* * \file problem032.cpp * \brief Project Euler - Probmel32 * * \author Takushi Homma (b1006018@fun.ac.jp) */ #include <iostream> #include <string> #include <algorithm> #include <set> using namespace std; int main(int argc, char **argv) { int ans = 0; set<int> set_ans; string </int></set></algorithm></string></iostream>…

Problem31

/* * \file problem031.cpp * \brief Projece Euler - Problem31 * * \author Takushi Homma (b1006018@fun.ac.jp) */ #include <iostream> using namespace std; #define LMT 200 int main(int argc, char **argv) { int coins[8] = {1, 2, 5, 10, 20, 50, 100, 200};</iostream>…

Problem30

/* * \file problem030.cpp * \brief Project Euler - Problem30 * * \author Takushi Homma (b1006018@fun.ac.jp) * \date 2010/03/07 16:13:33 */ #define FIG 5 int pow5(int n) { return n*n*n*n*n; } #include <iostream> using namespace std; int main(int argc</iostream>…

Problem29

/* * \file problem029.cpp * \brief Project Euler - Problem 29 * * \author Takushi Homma (b1006018@fun.ac.jp) * \date 2010/03/01 18:40:13 */ #include <iostream> #include <cmath> #include <set> using namespace std; #define MIN 2 #define MAX 100 int main(int argc,</set></cmath></iostream>…

Problem28

/* * \file problem028.cpp * \brief うずまき * * \author Takushi Homma (b1006018@fun.ac.jp) * \date 2010/03/01 18:40:13 */ #include <iostream> using namespace std; #define LEN 1001 int main(int argc, char **argv) { int ans = 1; int ru = 1; for (int l</iostream>…

Problem27

#include <iostream> #include <cmath> using namespace std; #define TLEN 2001000 #define LMTAB 1000 #define LMTN 10 // 素数テーブルの作成 void primeTable(bool t_prime[]) { unsigned int size = (unsigned int)ceil(sqrt((double)TLEN)); // 篩の大きさ // 篩にかけ</cmath></iostream>…

Problem26

#include <iostream> #include <vector> #include <utility> using namespace std; #define NUM 1000 typedef struct { int e; int d; } frac; bool isBreak(vector<frac> *pv, frac *fc) { bool f = false; for (vector<frac>::iterator it = pv->begin(), end = pv->end(); it != end; it++) { if </frac></frac></utility></vector></iostream>…

Problem25

#include <iostream> #include <string> using namespace std; #define NUM 1000 string reverse(string *s) { string t; t.resize(s->size()); for (string::size_type i = 0, e = s->size(); i < e; i++) { t.at(i) = s->at(e-i-1); } return t; } string sum(string *psrc, </string></iostream>…

Problem24

#include <iostream> #include <string> #include <algorithm> using namespace std; #define NUM 1000000 int main(int argc, char **argv) { string s = "0123456789"; for (int i = 1; i < NUM; i++) { next_permutation(s.begin(), s.end()); } cout << s << endl; return 0; }</algorithm></string></iostream>

Problem23

#include <iostream> #include <vector> #include <set> #include <cmath> using namespace std; #define LIMIT 28123 void aliquot(int n, set<int> *pset_pf) { pset_pf->insert(1); if(n == 2) { return; } bool *t = new bool [n]; memset(t, false, n); t[1] = true; for (int i = 2; i < n</int></cmath></set></vector></iostream>…

Problem22

#include <iostream> #include <fstream> #include <set> #include <string> using namespace std; void split(char *token, const char *delimit, set<string> *pv) { char *tk; tk = strtok(token, delimit); while (tk != NULL) { pv->insert(tk); tk = strtok(NULL, delimit); } } void split(str</string></string></set></fstream></iostream>…

Problem21

#include <iostream> #include <vector> #include <set> #include <cmath> using namespace std; #define NUM 10000 void aliquot(int n, set<int> *pset_pf) { pset_pf->insert(1); if(n == 2) { return; } bool *t = new bool [n]; memset(t, false, n); t[1] = true; for (int i = 2; i < n; </int></cmath></set></vector></iostream>…

Problem20

#include <iostream> #include <string> using namespace std; #define NUM 100 void multi(string *ps, int num) { string s(""); int c = 0; for (string::size_type i = ps->size(); i > 0; i--) { int n = (ps->at(i-1)-'0') * num + c; c = n/10; s += '0' + n%10; } if (</string></iostream>…

Problem19

#include <iostream> using namespace std; #define START 1901 #define END 2000 bool isLeap(int y) { if (y%4 != 0 || (y%100 == 0 && y%400 != 0)) { return false; } else { return true; } } int main(int argc, char **argv) { int md[13] = { 0, 31, 28, 31, 3</iostream>…

Problem18

#include <iostream> #include <sstream> #include <string> #include <vector> using namespace std; #define NUM "\ 75\n\ 95 64\n\ 17 47 82\n\ 18 35 87 10\n\ 20 04 82 47 65\n\ 19 01 23 75 03 34\n\ 88 02 77 73 07 63 67\n\ 99 65 04 28 06 16 70 92\n\ 41 41 26 56 83 40 80 70 33\n\ 4</vector></string></sstream></iostream>…

Problem17

#include <iostream> #include <string> using namespace std; #define NUM 1000 string numlen(int n) { if (n == 1000) { return "onethousand"; } string s; char fig1[10][7] = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" }; char</string></iostream>…

Problem16

#include <iostream> #include <string> using namespace std; #define NUM 1000 void multi(string *ps, int num) { string s(""); int c = 0; for (string::size_type i = ps->size(); i > 0; i--) { int n = (ps->at(i-1)-'0') * num + c; c = n/10; s += '0' + n%10; } if </string></iostream>…

Problem15

#include <iostream> #include <cmath> using namespace std; #define NUM 20 double fctr(int n) { double r = 1; for (int i = 2; i <= n; i++) { r *= i; } return r; } int main(int argc, char argv) { double ans; ans = fctr(NUM*2) / (fctr(NUM)*fctr(NUM)); printf("</cmath></iostream>…

Problem14

#include <iostream> using namespace std; #define NUM 1000000 int main(int argc, char **argv) { bool t[NUM]; memset(t, true, NUM); int ans = -1; int max = -1; for (int i = 2; i < NUM; i++) { if (t[i] == false) { continue; } unsigned int n = i; int l </iostream>…

Problem13

#include <iostream> #include <string> #include <vector> using namespace std; /* #define NUM "\ 37107287533902102798797998220837590246510135740250\ 46376937677490009712648124896970078050417018260538\ 74324986199524741059474233309513058123726617309629\ " */ #define N</vector></string></iostream>…

Problem 12

#include <iostream> #include <vector> #include <cmath> using namespace std; #define NUM 501 #define DST 100 void primeVector(vector<bool> *pv_table) { pv_table->at(0) = pv_table->at(1) = false; for (vector<bool>::size_type i = 2, end = (vector<bool>::size_type)ceil(sqrt((double)(pv</bool></bool></bool></cmath></vector></iostream>…

Problem 11

#include <iostream> #include <sstream> using namespace std; #define CLM 20 #define ROW 20 #define MAT "\ 08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 \ 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00 \ 81 49 31 73 55 79 14 29 93 71</sstream></iostream>…

Problem 10

#include <iostream> #include <vector> #include <cmath> using namespace std; #define NUM 2000000 #define DST 100000 void primeVector(vector<bool> *pv_table) { pv_table->at(0) = pv_table->at(1) = false; for (vector<bool>::size_type i = 2, end = (vector<bool>::size_type)ceil(sqrt((dou</bool></bool></bool></cmath></vector></iostream>…

Problem 9

#include <iostream> #include <cmath> using namespace std; #define SUM 1000 int main(int argc, char **argv) { int ans = -1; bool f = false; for (int a = 1; a < SUM; a++) { for (int b = a+1; b < SUM; b++) { int c = SUM - (a+b); if (a > b || b > c) { break; }</cmath></iostream>…