From a42152553b69cdb8d15d800409e6f4e9c88d2bf3 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Thu, 24 Sep 2015 15:26:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AF=AD=E8=A8=80=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/homework.js | 56 +++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/public/javascripts/homework.js b/public/javascripts/homework.js index 546d8b674..d897ba5e9 100644 --- a/public/javascripts/homework.js +++ b/public/javascripts/homework.js @@ -206,8 +206,9 @@ $(function(){ } if ($('#program-src').val().length<=0) { - if(language==4) - $('#program-src').val('\ + var src = ''; + if(language==4){ + src = '\ import java.io.*;\n\ import java.util.*;\n\ \n\ @@ -224,8 +225,55 @@ class Main\n\ //您的代码\n\ }\n\ }\n\ -'); - +'; + } + else if(language==1){ + src = '#include \n\ +\n\ +int main()\n\ +{\n\ + //获取参数方式 scanf\n\ + //int x =0;\n\ + //int y = 0;\n\ + //scanf("%d", &x);\n\ +\n\ + //结果输出使用prinf\n\ + //printf("%d",x);\n\ +\n\ + return 0;\n\ +}\n\ +'; + } else if(language==2){ +src = '\ +#include \n\ +using namespace std;\n\ +\n\ +int main()\n\ +{\n\ + //获取参数方式 cin\n\ + //int x =0;\n\ + //cin >> x;\n\ +\n\ + //结果输出使用 cout\n\ + //cout<<"1";\n\ +\n\ + return 0;\n\ +}\n\ +'; + } else if(language==3){ +src = '\ +import sys \n\ +\n\ +#获取参数方式,使用raw_input\n\ +#input = raw_input()\n\ +#a, b = input.split()\n\ +\n\ +#结果输出使用 print \n\ +#print (str(int(a)+int(b)))\n\ +'; + } + + $('#program-src').val(src); }; var editor = CodeMirror.fromTextArea(document.getElementById("program-src"), {