当前位置: 首页>>代码示例>>Golang>>正文


Golang Problem.Sample_output方法代码示例

本文整理汇总了Golang中OnlineJudge/models.Problem.Sample_output方法的典型用法代码示例。如果您正苦于以下问题:Golang Problem.Sample_output方法的具体用法?Golang Problem.Sample_output怎么用?Golang Problem.Sample_output使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OnlineJudge/models.Problem的用法示例。


在下文中一共展示了Problem.Sample_output方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: saveProblem

// /contest/:name/saveproblem
func (this *ContestController) saveProblem() {
	if !this.isAdmin() {
		return
	}
	contestName := this.Ctx.Input.Param(":name")
	id := this.GetSession("id")
	user := models.User{}
	user.Uid = id.(int)
	points, _ := strconv.Atoi(this.GetString("points"))
	//remove replace foe newlines
	sampleInput := strings.Replace(this.GetString("sample_input"), "\r", "", -1)
	sampleOutput := strings.Replace(this.GetString("sample_output"), "\r", "", -1)
	problem := models.Problem{
		Statement:   this.GetString("statement"),
		Description: this.GetString("description"),
		Constraints: this.GetString("constraints"),
		//Sample_input:  this.GetString("sample_input"),
		//Sample_output: this.GetString("sample_output"),
		Difficulty: this.GetString("difficulty"),
		Points:     points,
		Uid:        id.(int),
	}
	problem.Sample_output = sampleOutput
	problem.Sample_input = sampleInput
	problem.Type = "contest" + contestName
	pid, status := problem.Create()
	if status {
		id := strconv.Itoa(pid)
		this.Redirect("/contest/"+contestName+"/"+id, 302)
	}
	// handle the failure
}
开发者ID:JRonak,项目名称:OnlineJudge,代码行数:33,代码来源:ContestController.go

示例2: SaveProblem

// Save Problem
// To-do: Clean info before save - Ambigous
// To-do: Check login and user previlages - Done
func (this *ProblemController) SaveProblem() {

	if !this.isLoggedIn() {
		this.Redirect("/user/login", 302)
		return
	}

	//Redirect if user doesnt hold editor rights
	id := this.GetSession("id")
	user := models.User{}
	user.Uid = id.(int)
	if !user.IsEditor() {
		this.Redirect("/", 302)
		return
	}

	points, _ := strconv.Atoi(this.GetString("points"))
	//remove replace foe newlines
	sampleInput := strings.Replace(this.GetString("sample_input"), "\r", "", -1)
	sampleOutput := strings.Replace(this.GetString("sample_output"), "\r", "", -1)
	problem := models.Problem{
		Statement:   this.GetString("statement"),
		Description: this.GetString("description"),
		Constraints: this.GetString("constraints"),
		//Sample_input:  this.GetString("sample_input"),
		//Sample_output: this.GetString("sample_output"),
		Type:       this.GetString("type"),
		Difficulty: this.GetString("difficulty"),
		Points:     points,
		Uid:        id.(int),
	}
	problem.Sample_output = sampleOutput
	problem.Sample_input = sampleInput
	id, noerr := problem.Create()
	pid := strconv.Itoa(id.(int))
	if noerr == true {
		this.Redirect("/problem/"+pid, 302)
	}

	this.Data["title"] = "Create Problem "

	this.Layout = "layout.tpl"
	this.TplNames = "problem/create.tpl"
	this.LayoutSections = make(map[string]string)
	this.LayoutSections["HtmlHead"] = ""
	this.LayoutSections["Sidebar"] = ""
}
开发者ID:JRonak,项目名称:OnlineJudge,代码行数:50,代码来源:ProblemController.go


注:本文中的OnlineJudge/models.Problem.Sample_output方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。