Skip to content

Instantly share code, notes, and snippets.

View kazmura11's full-sized avatar

Kaz Mu kazmura11

View GitHub Profile
@kazmura11
kazmura11 / sample3.cpp
Created December 31, 2016 20:46
mapからvectorへ
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <iostream>
auto main()->int
{
std::ios::sync_with_stdio(false);
// vector -> map
@kazmura11
kazmura11 / sample2.cpp
Created December 31, 2016 20:46
vectorからmapへ
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <iostream>
auto main()->int
{
std::ios::sync_with_stdio(false);
// vector -> map
@kazmura11
kazmura11 / sample1.cpp
Created December 31, 2016 20:45
mapの最小値を求める
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <iostream>
auto main()->int
{
std::ios::sync_with_stdio(false);
std::unordered_map<std::string, int> m {{"a",1},{"b",2},{"c",3},{"d",4}};
@kazmura11
kazmura11 / sample.cpp
Last active August 29, 2015 14:22
How to use std::list
#include <iostream>
#include <list>
#include <algorithm>
#include <iterator>
int main()
{
std::list<int> ls { 12, 2, 3, 1, 5, 4, 13, 7, 8, 9, 10, 11, 6};
// とりあえず出力
std::copy(ls.begin(), ls.end(), std::ostream_iterator<int>(std::cout, " "));
scriptencoding utf-8
" vim:set ts=8 sts=2 sw=2 tw=0: (この行に関しては:help modelineを参照)
"
" An example for a Japanese version gvimrc file.
" 日本語版のデフォルトGUI設定ファイル(gvimrc) - Vim7用試作
"
" Last Change: 07-May-2013.
" Maintainer: MURAOKA Taro <koron.kaoriya@gmail.com>
"
" 解説:
@kazmura11
kazmura11 / main.c
Last active August 29, 2015 14:14
C言語のヘッダの書き方(main.c)
#define GLOBAL_VARIABLE_DEFINED /* 実体はこっち */
#include "global.h"
#include "a.h"
#include <stdio.h>
int main()
{
bar_proc();
g_FooBar.a = 1;
@kazmura11
kazmura11 / a.c
Created February 6, 2015 19:54
C言語のヘッダの書き方(a.c)
#include "a.h"
#include <stdio.h>
#include "Global.h"
// 構造体の完全な定義を書く
typedef struct tag_bar
{
int a;
int b;
char c[4];
@kazmura11
kazmura11 / a.h
Created February 6, 2015 19:53
C言語のヘッダの書き方(a.h)
#ifndef A_H_INCLUDED__
#define A_H_INCLUDED__
// 公開関数
void bar_proc();
// 下記は非公開 ちなみに.cにかいてstaticにする
//void bar_proc_1(Bar *bar);
//void bar_proc_2(Bar *bar, int n);
@kazmura11
kazmura11 / global.h
Created February 6, 2015 19:50
C言語のヘッダの書き方(global.h)
#ifndef GLOBAL_H_INCLUDED__
#define GLOBAL_H_INCLUDED__
// グローバル変数の名前の衝突を避けるための工夫
#ifdef GLOBAL_VARIABLE_DEFINED
# define GLOBAL /* INSTANCE */
#else
# define GLOBAL extern /* EXTERN */
#endif /* GLOBAL_VARIABLE_DEFINED */
@kazmura11
kazmura11 / MapTest.java
Last active August 29, 2015 14:13
Mapの使いどき
package prin.com;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
// なんでこんな構造になっているのかっていうツッコミはあると思いますが
// 説明のため あくまで簡易的な例です。
// idはA00000の形式で作られていて最初のアルファベットで部署が紐づいている