Skip to content

Instantly share code, notes, and snippets.

cout.precision(16);
func int debug(mesh &Th) {
cout << "Nb of boundary elements: " << Th.nbe << ",\t"
<< "Nb of nodes: " << Th.nv << ",\t"
<< "Nb of triangles: " << Th.nt << ",\t"
<< "Area: " << Th.measure << "\n\n";
return 0;
}
int main() {
int i = 0;
int const ci = 0;
int * pi;
pi = &i;
// pi = &ci;
int const * pci;
pci = &i;
#include <functional>
#include <iostream>
template<typename T, typename... U>
using Fn = std::function<T(U...)>;
int add(int x, int y) {
return x + y;
}
#include <iostream>
#include<vector>
#include<algorithm>
#include<iterator>
int main() {
std::vector<int> v = {0,1,2,3,4};
std::vector<int> w;
std::copy(v.begin() + 1, v.begin() + 4, std::back_inserter(w));
for (int n : w) {
@1995hnagamin
1995hnagamin / kakugen.scm
Created February 10, 2016 08:31
格言を自動生成する
(use srfi-27)
(define (sample lst)
(list-ref lst (random-integer (length lst))))
(define (assoc-all alist obj)
(map cdr
(filter (lambda (x)
(eq? (car x) obj))
alist)))
@1995hnagamin
1995hnagamin / iteraton_by_iota.cpp
Created February 7, 2016 07:00
ユーザー定義リテラルで整数のRange-based for
#include <iostream>
namespace iota {
class Iter {
public:
Iter(): iter(0) {}
Iter(int x): iter(x) {}
int operator*() {
return iter;
}
@1995hnagamin
1995hnagamin / template_template_parameter.cpp
Created February 7, 2016 05:49
テンプレートテンプレートパラメータ
template<typename T> struct C {};
template <template <typename T> class C>
class D {
C<int> cint;
C<double> cdouble;
};
int main() {
D<C> d;
@1995hnagamin
1995hnagamin / app.js
Created December 16, 2015 21:55
P2P chat for plural persons with WebRTC
function add() {
var id = document.getElementById("id").value;
add_friend(id);
}
function add_friend(id, conn) {
if (typeof conn == "undefined") {
conn = peer.connect(id);
}
connections[id] = conn;

全般

  • vectorの要素数は正しいですか? (足りなくてもエラーは出ないことがある)
  • 関数の名前を変更しましたか?
  • 添字は適切ですか?
  • 組合せ列挙で自分を数え忘れていませんか?
  • IO時にデータを正規化していますか?(0-idxed, 座標圧縮, グラフ構築)
  • 半開区間を使っていますか?
  • maxとminを間違えていませんか?
  • 深さ優先探索でスタックオーバーフローしていませんか?
  • 再帰関数内の条件分岐の順序は適切ですか?
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
const int INF = INT_MAX/3;
struct segment_tree {
int n;
vector<int> dat;