Harigami
ログイン
Harigamiは、ログイン不要のコード共有サービスです。コードの投稿後に発行されるURLでコードを共有できます。
PythonやRubyなど一部の言語は、投稿後にオンラインで実行することもできます。
誰でも無料で使えて、広告もありません。コードレビューやスニペットの代わりに使ってみてください。


詳細設定
+
anonymous タイトルなし
C++
#include <iostream>
#include <map>
using std::map;
using std::ostream;

typedef map<char, int> Plate;

//*
ostream& operator << (ostream& os, Plate& p) {
	for (auto m_itr : p) {
		os << m_itr.first << " " << m_itr.second << std::endl;
	}
	return os;
}
//*/

class Dog {
	public:
	Dog(Plate& _plate, char _c) {
		plate = &_plate;
		c = _c;
		std::cout << "debug hoge" << *plate << std::endl; // debug
	}

	void bite() {
		std::cout << "debug fuga" << *plate << std::endl; // debug
		plate->at(c)--;
	}

	private:
	Plate* plate;
	char c;
};

int main() {

	Plate shared_plate;
	shared_plate['p'] = 10;
	shared_plate['r'] = 10;

	Dog pochi = Dog(shared_plate, 'p');
	Dog ryo = Dog(shared_plate, 'r');

	pochi.bite();
	ryo.bite();

	std::cout << "debug " << std::endl << shared_plate << std::endl; // debug


	std::cout << "\e[38;5;0m\e[48;5;40m --- end ---  \e[m" << std::endl; // debug
	return 0;
}

  • 0
  • 0
anonymous タイトルなし
Python
Satisfy note a gooddonation recompense you. http://qryzithmanchi.tk/1l9l
  • 0
  • 0
anonymous タイトルなし
HTML
<p><strong>👇お得情報・新着ニュースも配信中♪ ジャパカジLINE&nbsp;</strong></p>

<p>&nbsp;お得情報・新着ニュースも配信してます♪&nbsp; つぶやき、お問い合わせもこちらから!</p>

<div><a href="https://line.me/ti/p/uVKk2Tsspk" target="_blank" title="ジャパカジLINEはじめました!詳細ページへ"><img alt="ジャパカジLINEはじめました!詳細ページへ" class="full hidden-xs" src="/images/home/images/line/japacasi-line-ad-header-pc_680x87.jpg" style="" /></a></div>

<div><a href="https://line.me/ti/p/uVKk2Tsspk" target="_blank" title="ジャパカジLINEはじめました!詳細ページへ"><img alt="ジャパカジLINEはじめました!詳細ページへ" class="full visible-xs" src="/images/home/images/line/japacasi-line-ad-header-mobile_351x89.jpg" style="" /></a></div>

<p>&nbsp;</p>

<p><strong>👇雑談や質問が気軽にできる♪&nbsp;ジャパカジ掲示板</strong></p>

<p>ユーザー同士の交流や雑談、ジャパカジスタッフへの<a href="/forum" title=""><u>お問い合わせ</u></a>、なんでも大歓迎!</p>

<div><a href="/forum" title="ジャパカジ掲示板はじめました!詳細ページへ"><img alt="ジャパカジ掲示板はじめました!詳細ページへ" class="full hidden-xs" src="/images/home/images/casino-forum-ad-pc_680x87.jpg" style="" /></a></div>

<div><a href="/forum" title="ジャパカジ掲示板はじめました!詳細ページへ"><img alt="ジャパカジ掲示板はじめました!詳細ページへ" class="full visible-xs" src="/images/home/images/casino-forum-ad-mobile_680x172.jpg" style="" /></a></div>
  • 0
  • 0
anonymous タイトルなし
HTML
<p><strong>👇雑談や質問が気軽にできる♪&nbsp;ジャパカジ掲示板</strong></p>

<p>ユーザー同士の交流や雑談、ジャパカジスタッフへの<a href="/forum" title=""><u>お問い合わせ</u></a>、なんでも大歓迎!</p>

<div><a href="/forum" title="ジャパカジ掲示板はじめました!詳細ページへ"><img alt="ジャパカジ掲示板はじめました!詳細ページへ" class="full hidden-xs" src="/images/home/images/casino-forum-ad-pc_680x87.jpg" style="" /></a></div>

<div><a href="/forum" title="ジャパカジ掲示板はじめました!詳細ページへ"><img alt="ジャパカジ掲示板はじめました!詳細ページへ" class="full visible-xs" src="/images/home/images/casino-forum-ad-mobile_680x172.jpg" style="" /></a></div>
  • 0
  • 0
anonymous タイトルなし
HTML
<p><strong>👇お得情報・新着ニュースも配信中♪ ジャパカジLINE&nbsp;</strong></p>

<p>&nbsp;お得情報・新着ニュースも配信してます♪&nbsp; つぶやき、お問い合わせもこちらから!</p>

<div><a href="https://line.me/ti/p/uVKk2Tsspk" target="_blank" title="ジャパカジLINEはじめました!詳細ページへ"><img alt="ジャパカジLINEはじめました!詳細ページへ" class="full hidden-xs" src="/images/home/images/line/japacasi-line-ad-header-pc_680x87.jpg" style="" /></a></div>

<div><a href="https://line.me/ti/p/uVKk2Tsspk" target="_blank" title="ジャパカジLINEはじめました!詳細ページへ"><img alt="ジャパカジLINEはじめました!詳細ページへ" class="full visible-xs" src="/images/home/images/line/japacasi-line-ad-header-mobile_351x89.jpg" style="" /></a></div>
  • 0
  • 0
anonymous タイトルなし
Python
a = input('Hello>')
print("Hello :", a)
  • 0
  • 0
anonymous タイトルなし
Go
package main
import (
	"fmt"
	"strings"
	"os"
)
func main() {
	args := os.Args
	vt := var_type()
	vtype := strings.Split(vt, ",")
	support_vtype := []string{"int", "char", "double"}
	if len(args) == 2 {
		filename := args[1]
		file, err := os.Open(filename)
		if err != nil{
			fmt.Printf("No Such file : %s", filename)
			os.Exit(0)
		}
		nfilename,ext := get_ext_filename(filename)
		if ext != "sl"{
			fmt.Println(filename, "is not SasaLan File")
			os.Exit(0)
		}
		buf := make([]byte, 1024)
		var add_code string
		for {
			n,err := file.Read(buf)
			if n == 0{
				break
			}
			if err != nil{
				fmt.Println("Read Error")
				break
			}
			code := string(buf[:n])
			add_code += code
		}
		nl_split := strings.Split(add_code, "\n")
		size := len(nl_split)
		var var_string string
		var var_type_s string
		in_if, in_func := "0", "0"
		var func_code string
		var main_code string
		main_code += "#include <stdio.h>\nint main(void){\n"
		for i := 0;i < size;i++{
			code := nl_split[i]
			space_split := strings.Split(code, " ")
			if code == ""{
				continue
			}
			if string(code[0]) == "#" {
				var comment_value string
				for i := 0;i < len(code);i++ {
					if i == 0{
						continue
					} else {
						comment_value += string(code[i])
					}
				}
				add_code := "/*" + comment_value + "*/\n"
				main_code += add_code
			} else if len(space_split) >= 2 {
				if space_split[0] == "if" {
					var judge_formula string
					for i,value := range space_split {
						if i == 0 {
							continue
						} else if i == 1 {
							judge_formula += value
						} else {
							judge_formula += " " + value
						}
					}
					add_code := if_code(judge_formula)
					in_if += ",1"
					main_code += add_code
				}
			} else if code == "e" {
				if_sp, func_sp := strings.Split(in_if, ","), strings.Split(in_func, ",")
				lengh1, lengh2 := len(if_sp) - 1, len(func_sp) - 1
				ires, fres := if_sp[lengh1], func_sp[lengh2]
				if ires == "1" {
					main_code += "}\n"
				} else if fres == "1" {
					func_code += "}"
				}
			}
			if space_split[0] == "pr" {
				var pr_value string
				for i := 1;i < len(code);i++{
					if i == 0 || i == 1 || i == 2{
						continue
					} else {
						pr_value += string(code[i])
					}
				}
				add_code := pr_code(pr_value, strings.Split(var_string, ","), strings.Split(var_type_s, ","))
				main_code += add_code
			}
			var_split1 := strings.Split(code, string(vtype[0]))
			var_split2 := strings.Split(code, string(vt[1]))
			var_split3 := strings.Split(code, "f:")
			if var_split1[0] == "" {
				var_name_value := var_split1[1]
				line_split1 := strings.Split(var_name_value, "=")
				var_name,var_value := line_split1[0], line_split1[1]
				lengh1, lengh2 := len(strings.Split(var_name, " ")), len(strings.Split(var_value, " "))
				var vname string
				var vvalue string
				if lengh1 == 2 && lengh2 == 2{
					var_name, var_value := strings.Split(var_name, " ")[0], strings.Split(var_value, " ")[1]
					vname += var_name
					vvalue += var_value
				}
				var_type := support_vtype[0]
				add_code := var_code(var_type, vname, vvalue)
				if len(var_string) == 0{
					var_string += vname
				} else {
					var_string += "," + vname
				}
				if len(var_type_s) == 0{
					var_type_s += var_type
				} else {
					var_type_s += "," + var_type
				}
				main_code += add_code
			} else if var_split2[0] == "s" {
				var_name_value := var_split2[1]
				line_split1 := strings.Split(var_name_value, "=")
				var_name,var_value := line_split1[0], line_split1[1]
				lengh1, lengh2 := len(strings.Split(var_name, " ")), len(strings.Split(var_value, " "))
				var vname string
				var vvalue string
				if lengh1 >= 2 && lengh2 >= 2 {
					var_name := strings.Split(var_name, " ")[0]
					var_value_sp := strings.Split(var_value, " ")
					var res string
					for i := 0;i < len(var_value_sp);i++ {
						if i == 0{
							continue
						} else if i == 1{
							res += var_value_sp[i]
						} else {
							res += " " + var_value_sp[i]
						}
					}
					vvalue += res
					vname += var_name
				} else {
					vname += var_name
					vvalue += var_value
				}
				var_type := support_vtype[1]
				add_code := var_code(var_type, vname, vvalue)
				if len(var_string) == 0{
					var_string += vname
				} else {
					var_string += "," + vname
				}
				if len(var_type_s) == 0{
					var_type_s += var_type
				} else {
					var_type_s += "," + var_type
				}
				main_code += add_code
			} else if var_split3[0] == ""{ //float && コード変換
				var_name_value := var_split3[1]
				line_split1 := strings.Split(var_name_value, "=")
				var_name, var_value := line_split1[0], line_split1[1]
				lengh1, lengh2 := len(strings.Split(var_name, " ")), len(strings.Split(var_value, " "))
				var vname string
				var vvalue string
				if lengh1 >= 2 && lengh2 >= 2 {
					var_name := strings.Split(var_name, " ")[0]
					var_value_sp := strings.Split(var_value, " ")
					var res string
					for i,value := range var_value_sp {
						if i == 0 {
							continue
						} else if i == 1 {
							res += value
						} else {
							res += " " + value
						}
					}
					vname += var_name
					vvalue += res
				} else {
					vname += var_name
					vvalue += var_value
				}
				var_type := support_vtype[2]
				add_code := var_code(var_type, vname, vvalue)
				if len(var_string) == 0{
					var_string += vname
				} else {
					var_string += "," + vname
				}
				if len(var_type_s) == 0{
					var_type_s += var_type
				} else {
					var_type_s += "," + var_type
				}
				main_code += add_code
			}
		}
		if string(main_code[len(main_code) - 1]) !="}" {
			main_code += "}"
		}
		cfilename := nfilename + ".c"
		nfile,err := os.Create(cfilename)
		if err != nil{
			fmt.Println("Write Error")
			os.Exit(0)
		}
		nfile.Write(([]byte)(main_code))
		fmt.Printf("Output C File : %s\n", cfilename)
	} else {
		fmt.Println("sasalan [filename]")
		os.Exit(0)
	}
}
func get_ext_filename(filename string) (string, string) {
	split_arr := strings.Split(filename, ".")
	max_lengh := len(split_arr) - 1
	ext := split_arr[max_lengh]
	return split_arr[0],ext
}
func var_type() string {
	filename := "doc/var_type"
	var code string
	file,err := os.Open(filename)
	if err != nil{
		fmt.Println("Error")
	}
	buf := make([]byte, 1024)
	for {
		n,err := file.Read(buf)
		if n == 0 {
			break
		}
		if err != nil{
			fmt.Println("Read Error")
		}
		ncode := string(buf[:n])
		code += ncode
	}
	tl := strings.Split(code, "\n")[0]
	return tl
}
func var_code(var_type string, var_name string, var_value string) string {
	var res string
	if var_type == "int" {
		code := fmt.Sprintf("int %s = %s;\n", var_name, var_value)
		res += code
	} else if var_type == "char"{
		code := fmt.Sprintf("char %s[] = %s;\n", var_name, var_value)
		res += code
	} else if var_type == "double" {
		code := fmt.Sprintf("float %s = %sf;\n", var_name, var_value)
		res += code
	}
	return res
}
func pr_code(put_string string, var_array []string, var_type_array []string) string {
	var judge1 rune = '"'
	var res string
	pr_split1 := strings.Split(put_string, string(judge1))
	join_split1 := strings.Split(put_string, ",")
	if len(pr_split1) == 3 {
		res += fmt.Sprintf("printf(%s);\n", put_string)
		return res
	}
	if len(join_split1) >= 2 {
		base := "printf(" + string(judge1)
		var after_str string
		judge2 := "0"
		for _,v := range join_split1 {
			fmt.Println(v)
			if string(v[0]) == string(judge1) {
				judge2 += ",0"
				if len(after_str) == 0 {
					after_str += v
				} else {
					after_str += "," + v
				}
				base += "%s"
				continue
			} else if string(v[len(v) - 1]) == string(judge1) {
				judge2 += ",1"
				if len(after_str) == 0 {
					after_str += v
				} else {
					after_str += "," + v
				}
			} else if strings.Split(judge2, ",")[len(strings.Split(judge2, ",")) - 1] == "1" {
				if len(after_str) == 0 {
					after_str += v
				} else {
					after_str += "," + v
				}
			} else {
				if len(after_str) == 0 {
					after_str += v
				} else {
					after_str += "," + v
				}
				var vtype string
				var res2 string
				for i := 0;i < len(var_array);i++ {
					if var_array[i] == v {
						res2 += "comp"
						vtype += var_type_array[i]
						break
					} else {
						res2 += "not"
					}
				}
				if res2 == "not" {
					fmt.Printf("There is not variable %s", v)
					os.Exit(0)
				}
				if vtype == "int" {
					base += "%d"
				} else if vtype == "char" {
					base += "%s"
				} else if vtype == "double" {
					base += "%f"
				}
				continue
			}
		}
		base += string(judge1) + ", " + after_str + ");\n"
		return base
	}
	var res2 string
	var vtype string
	for i := 0;i < len(var_array);i++ {
		if var_array[i] == put_string{
			res2 += "comp"
			vtype += var_type_array[i]
			break
		} else {
			res2 += "not"
		}
	}
	if res2 == "not" {
		fmt.Printf("There is not variable %s", put_string)
		os.Exit(0)
	} 
	if vtype == "int" {
		 code := "printf(" + string(judge1) + "%d" + string(judge1) + ", " + put_string + ");\n"
		 res += code
	} else if vtype == "char" {
		code := "printf(" + string(judge1) + "%s" + string(judge1) + ", " + put_string + ");\n"
		res += code
	} else if vtype == "double" {
		code := "printf(" + string(judge1) + "%f" + string(judge1) + ", " + put_string + ");\n"
		res += code
	}
	return res
}
func if_code(judge_formula string) string {
	return fmt.Sprintf("if (%s) {\n", judge_formula)
}
  • 0
  • 0
Tomoaki Sugiyama タイトルなし
Python
  • 0
  • 0
anonymous タイトルなし
Python
//@version=3
study("MTF 8 SMA/EMA", overlay=true)

// SMA or EMA
SEswitch = input(title="on:EMA off:SMA", type=bool, defval=true)

//Get EMA Values
maA = input(title='MA1 期間', type=integer, minval=1, step=1, defval=10)
maB = input(title='MA2 期間', type=integer, minval=1, step=1, defval=75)
maC = input(title='MA3 期間', type=integer, minval=1, step=1, defval=10)
maD = input(title='MA4 期間', type=integer, minval=1, step=1, defval=20)
maE = input(title='MA5 期間', type=integer, minval=1, step=1, defval=75)
maF = input(title='MA6 期間', type=integer, minval=1, step=1, defval=10)
maG = input(title='MA7 期間', type=integer, minval=1, step=1, defval=75)
maH = input(title='MA8 期間', type=integer, minval=1, step=1, defval=10)

//Set resolutions
resA = input(title='MA1 時間足', type=resolution, defval="15")
resB = input(title='MA2 時間足', type=resolution, defval="15")
resC = input(title='MA3 時間足', type=resolution, defval="60")
resD = input(title='MA4 時間足', type=resolution, defval="60")
resE = input(title='MA5 時間足', type=resolution, defval="60")
resF = input(title='MA6 時間足', type=resolution, defval="240")
resG = input(title='MA7 時間足', type=resolution, defval="240")
resH = input(title='MA8 時間足', type=resolution, defval="1440")

//Set switches
emaAswitch = input(title="MA1 On/Off", type=bool, defval=true)
emaBswitch = input(title="MA2 On/Off", type=bool, defval=true)
emaCswitch = input(title="MA3 On/Off", type=bool, defval=true)
emaDswitch = input(title="MA4 On/Off", type=bool, defval=true)
emaEswitch = input(title="MA5 On/Off", type=bool, defval=true)
emaFswitch = input(title="MA6 On/Off", type=bool, defval=true)
emaGswitch = input(title="MA7 On/Off", type=bool, defval=true)
emaHswitch = input(title="MA8 On/Off", type=bool, defval=true)

//get data
dataA = security(tickerid, resA, SEswitch ? ema(close, maA) : sma(close, maA))
dataB = security(tickerid, resB, SEswitch ? ema(close, maB) : sma(close, maB))
dataC = security(tickerid, resC, SEswitch ? ema(close, maC) : sma(close, maC))
dataD = security(tickerid, resD, SEswitch ? ema(close, maD) : sma(close, maD))
dataE = security(tickerid, resE, SEswitch ? ema(close, maE) : sma(close, maE))
dataF = security(tickerid, resF, SEswitch ? ema(close, maF) : sma(close, maF))
dataG = security(tickerid, resG, SEswitch ? ema(close, maG) : sma(close, maG))
dataH = security(tickerid, resH, SEswitch ? ema(close, maH) : sma(close, maH))


//Plotting
plot(emaAswitch ? dataA : na, color=lime, linewidth=3)
plot(emaBswitch ? dataB : na, color=aqua, linewidth=3)
plot(emaCswitch ? dataC : na, color=orange, linewidth=3)
plot(emaDswitch ? dataD : na, color=yellow, linewidth=3)
plot(emaEswitch ? dataE : na, color=olive, linewidth=3)
plot(emaFswitch ? dataF : na, color=fuchsia, linewidth=3)
plot(emaGswitch ? dataG : na, color=maroon, linewidth=3)
plot(emaHswitch ? dataH : na, color=white, linewidth=4)

study("London_NY", overlay=true)
t1 = time(period, "0900-1700")
t2 = time(period, "1600-2200")
t3 = time(period, "2100-0600")

tokyo = na(t1) ? na : blue
London = na(t2) ? na : white
NY = na(t3) ? na : black

bgcolor(tokyo, title1="tokyo")
bgcolor(London, title2="London")
bgcolor(NY, title3="NY")
  • 0
  • 0
anonymous タイトルなし
Python
//@version=3
study(title="MTF Bollinger Bands", shorttitle="MTF 3 BB", overlay=true)

onoffA = input(true, "BB1 ON/OFF")
resA = input(title='BB1時間足 (BB1 Time Frame)', type=resolution, defval="60")
sigmaA = input(1,title='BB1偏差 (BB1 Sigma)', step=1, minval=1, maxval=3)
onoffB = input(true, "BB2 ON/OFF")
resB = input(title='BB2時間足 (BB1 Time Frame)', type=resolution, defval="60")
sigmaB = input(2,title='BB2偏差 (BB2 Sigma)', step=1, minval=1, maxval=3)
onoffC = input(true, "BB3 ON/OFF")
resC = input(title='BB4時間足 (BB1 Time Frame)', type=resolution, defval="60")
sigmaC = input(3,title='BB3偏差 (BB3 Sigma)', step=1, minval=1, maxval=3)

devA = security(tickerid, resA, stdev(close,20))
basisA = security(tickerid, resA, sma(close,20))
devB = security(tickerid, resB, stdev(close,20))
basisB = security(tickerid, resB, sma(close,20))
devC = security(tickerid, resC, stdev(close,20))
basisC = security(tickerid, resC, sma(close,20))


upper_1 = onoffA ? (basisA + devA * sigmaA) : na
lower_1 = onoffA ? (basisA - devA * sigmaA) : na
upper_2 = onoffB ? (basisB + devB * sigmaB) : na
lower_2 = onoffB ? (basisB - devB * sigmaB) : na
upper_3 = onoffC ? (basisC + devC * sigmaC) : na
lower_3 = onoffC ? (basisC - devC * sigmaC) : na


plot(basisA, color=red,title='BB1 Basis')
plot(basisB, color=orange,title='BB2 Basis')
plot(basisC, color=red,title='BB3 Basis')
u1 = plot(upper_1, color=blue,title='BB1 Upper')
l1 = plot(lower_1, color=blue,title='BB1 Lower')
u2 = plot(upper_2, color=green,title='BB2 Upper')
l2 = plot(lower_2, color=green,title='BB2 Lower')
u3 = plot(upper_3, color=purple,title='BB3 Upper')
l3 = plot(lower_3, color=purple,title='BB3 Lower')

fill(u1,l1, color=white, transp=90,title='BB1')
fill(u2,l2, color=white, transp=90,title='BB2')
fill(u3,l3, color=white, transp=90,title='BB3')
  • 0
  • 0