You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

homework.js 23 kB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. $(function(){
  2. //提交作业
  3. var bt=baidu.template;
  4. bt.LEFT_DELIMITER='<!';
  5. bt.RIGHT_DELIMITER='!>';
  6. var tested = false;
  7. var valid_form = function() {
  8. var src = $('#program-src').val();
  9. var title = $('#program-title').val();
  10. if (!src) {
  11. var htmlvalue = "</br><div style='width:550px;text-align:center'>请输入正确的代码!</div></br><div style='width:67px; margin:0 auto; text-align:center'><a href='javascript:void(0);' class='Blue-btn' onclick='hideModal()'>确定</a></div>";
  12. pop_up_box(htmlvalue,580,30,50);
  13. return false;
  14. }
  15. if (!title) {
  16. var htmlvalue = "</br><div style='width:550px;text-align:center'>请输入标题!</div></br><div style='width:67px; margin:0 auto; text-align:center'><a href='javascript:void(0);' class='Blue-btn' onclick='hideModal()'>确定</a></div>";
  17. pop_up_box(htmlvalue,580,30,50);
  18. return false;
  19. }
  20. return true;
  21. };
  22. var test_program = function(cb){
  23. $('#test-program-btn').hide();
  24. var homework_id = $('#test-program-btn').attr('data-homework-id');
  25. var student_work_id = $('#test-program-btn').attr('data-student-work-id');
  26. var src = $('#program-src').val();
  27. var title = $('#program-title').val();
  28. var is_test = $('input[name=is_test]').val();
  29. if(!valid_form()){
  30. $('#test-program-btn').show();
  31. return;
  32. }
  33. //先测试一次并返回测试集个数及结果再判断是否需要继续进行测试
  34. var test_post = function(i, testid){
  35. $.post(
  36. '/student_work/program_test_ex',
  37. {homework: homework_id, student_work_id: student_work_id,
  38. src: src, title: title, is_test: is_test,tIndex:i,
  39. testid: testid},
  40. function(data,status){
  41. if (data.status==-4 || data.status==-5 ){
  42. //弹框
  43. var root_path = getRootPath();
  44. var forums_1_path = root_path + "/forums/1"
  45. var htmlvalue = "</br><div style='width:430px;text-align:center;margin:0 auto' >您的程序引发了不知名异常,请在公共贴吧提交您的代码进行意见反馈,我们处理后会立即联系您,谢谢!</div><div style='width:550px;text-align:center'><a target='_Blank' href="+forums_1_path+">点我进入反馈页面</a></div>";
  46. pop_up_box(htmlvalue,580,30,50);
  47. $('#test-program-btn').show();
  48. return;
  49. }
  50. else if (data.status==-3){
  51. var htmlvalue = "</br><div style='width:550px;text-align:center'>对不起,服务器繁忙请稍后再试!</div></br><div style='width:67px; margin:0 auto; text-align:center'><a href='javascript:void(0);' class='Blue-btn' onclick='hideModal()'>确定</a></div>";
  52. pop_up_box(htmlvalue,580,30,50);
  53. $('#test-program-btn').show();
  54. return;
  55. }
  56. var tSeq = data.tseq;
  57. var tCount = data.tcount;
  58. console.log("tSeq="+tSeq);
  59. console.log("tCount="+tCount);
  60. tested = true;
  61. console.log(data);
  62. if(data.index <=0){
  63. data.index = $('.ProResultTop').length+1;
  64. }
  65. var html=bt('t:result-list',data);
  66. $('.ProResult').prepend(html);
  67. if (data.status==0 && is_test != 'true') {
  68. if (typeof cb == 'function') {cb(data);$('#test-program-btn').show(); return;}
  69. var htmlvalue = "</br><div style='width:550px;text-align:center'>答题正确,是否立刻提交?</div></br><div style='width:164px; margin:0 auto; text-align:center'><a href='javascript:void(0);' class='Blue-btn fl' onclick='submit_code()'>确定</a><a href='javascript:void(0);' class='Blue-btn fl' onclick='hideModal()'>取消</a></div><script>function submit_code(){$('.HomeWorkCon form').submit();hideModal();}</script>";
  70. pop_up_box(htmlvalue,580,30,50);
  71. $('#test-program-btn').show();
  72. return;
  73. }
  74. //2 超时 -2 编译错误 测试结束
  75. if (data.status == 2 || data.status == -2 || tSeq >= tCount ){
  76. if (typeof cb == 'function') {cb(data);$('#test-program-btn').show(); return;}
  77. $('#test-program-btn').show();
  78. return;
  79. }
  80. test_post(i+1, data.testid);
  81. }
  82. ).fail(function(xhr, status){
  83. if(status == 'timeout'){
  84. var htmlvalue = "</br><div style='width:550px;text-align:center'>您的答案超时了, 请检查代码是否存在死循环的错误!</div></br><div style='width:67px; margin:0 auto; text-align:center'><a href='javascript:void(0);' class='Blue-btn' onclick='hideModal()'>确定</a></div>";
  85. pop_up_box(htmlvalue,580,30,50);
  86. } else {
  87. var htmlvalue = "</br><div style='width:550px;text-align:center'>对不起,服务器繁忙请稍后再试!</div></br><div style='width:67px; margin:0 auto; text-align:center'><a href='javascript:void(0);' class='Blue-btn' onclick='hideModal()'>确定</a></div>";
  88. pop_up_box(htmlvalue,580,30,50);
  89. }
  90. $('#test-program-btn').show();
  91. return;
  92. });
  93. };
  94. test_post(1, 0);
  95. };
  96. $('#test-program-btn').on('click', test_program);
  97. $('#commit-program-work-btn').on('click', function(){
  98. if(!valid_form()){
  99. return;
  100. }
  101. if($('.ProResult .ProResultTop').length<=0){
  102. var htmlvalue = "</br><div style='width:550px;text-align:center'>测试后才能提交,是否立刻测试?</div></br><div style='width:164px; margin:0 auto; text-align:center'><a href='javascript:void(0);' id='code-test-button' class='Blue-btn fl'>确定</a><a href='javascript:void(0);' class='Blue-btn fl' onclick='hideModal()'>取消</a></div>";
  103. pop_up_box(htmlvalue,580,30,50);
  104. $("#code-test-button").on('click',function(){
  105. test_program();
  106. hideModal();
  107. });
  108. return;
  109. }
  110. if (!tested) {
  111. test_program(function(data){
  112. if (data.status!=0) {
  113. var htmlvalue = "</br><div style='width:550px;text-align:center'>测试不通过,是否强制提交?</div></br><div style='width:164px; margin:0 auto; text-align:center'><a href='javascript:void(0);' class='Blue-btn fl' onclick='submit_code()'>确定</a><a href='javascript:void(0);' class='Blue-btn fl' onclick='hideModal()'>取消</a></div><script>function submit_code(){$('.HomeWorkCon form').submit();hideModal();}</script>";
  114. pop_up_box(htmlvalue,580,30,50);
  115. return;
  116. };
  117. $(".HomeWorkCon form").submit();
  118. });
  119. return;
  120. }
  121. $(".HomeWorkCon form").submit();
  122. });
  123. $('form.edit_student_work').on('keydown', '#program-src', function(){
  124. tested = false;
  125. });
  126. //发布作业
  127. $('#program-src').focus(function(){
  128. $(this).css('height', '100px');
  129. });
  130. var datepickerOptions={dateFormat:'yy-mm-dd',firstDay:0,showWeek:true,showOtherMonths:true,selectOtherMonths:true};
  131. $('input.date-input').datepicker(datepickerOptions);
  132. $('a.pic_date').on('click', function(){
  133. $(this).parent().prev().first().focus();
  134. })
  135. $("#NoticePopupBox").dialog({
  136. modal: true,
  137. autoOpen: false,
  138. dialogClass: 'BluePopupBox',
  139. minWidth: 500
  140. });
  141. $('#NoticePopupBox').parent().resizable("disable");
  142. $('#NoticePopupBox').parent().removeClass("ui-state-disabled");
  143. $('#NoticePopupBox').parent().css("border","3px solid #269ac9").css("padding","10px");
  144. $('a#switch_type').live('click', function(){
  145. if($("input[name=homework_type]").val() == "3"){
  146. $("#NoticePopupBox" ).dialog("close");
  147. $("input[name=homework_type]").val(1);
  148. $('span.group_detail_info').text('');
  149. $("#group_setting a").removeClass("fontBlue2");
  150. $("#BluePopupBox").dialog("open");
  151. $(".ui-dialog-titlebar").hide();
  152. $("a.CloseBtn").on('click', function(){
  153. $("#BluePopupBox" ).dialog("close");
  154. });
  155. var inputs = document.getElementsByName("program[input][]");
  156. var outputs = document.getElementsByName("program[output][]");
  157. if (inputs.length == outputs.length) {
  158. for (var i=0; i<inputs.length; i++) {
  159. autoTextarea2(inputs[i], outputs[i]);
  160. autoTextarea2(outputs[i], inputs[i]);
  161. }
  162. }
  163. $(inputs[0]).focus();
  164. } else if($("input[name=homework_type]").val() == "2") {
  165. $("#NoticePopupBox" ).dialog("close");
  166. $("input[name=homework_type]").val(1);
  167. $('span.program_detail_info').text("");
  168. $("span.program_detail_info").removeClass("fontBlue2");
  169. $("#program_setting a").removeClass("fontBlue2");
  170. $("#GroupPopupBox").dialog("open");
  171. $(".ui-dialog-titlebar").hide();
  172. $("a.popClose").on('click', function(){
  173. reset_group_attr();
  174. $("#GroupPopupBox" ).dialog("close");
  175. });
  176. $("#cancel_group").on('click', function(){
  177. reset_group_attr();
  178. $("#GroupPopupBox" ).dialog("close");
  179. });
  180. $('#min_num').focus();
  181. }
  182. });
  183. $("#BluePopupBox").dialog({
  184. modal: true,
  185. autoOpen: false,
  186. dialogClass: 'BluePopupBox',
  187. minWidth: 771
  188. });
  189. $('#BluePopupBox').parent().resizable("disable");
  190. $('#BluePopupBox').parent().removeClass("ui-state-disabled");
  191. $('#BluePopupBox').parent().css("border","3px solid #269ac9").css("padding","10px");
  192. $('#BluePopupBox').parent().css("position","fixed");
  193. $('a.ProBtn').live('click', function(){
  194. if($("input[name=homework_type]").val() == "3"){
  195. $("#NoticePopupBox").dialog("open");
  196. $(".ui-dialog-titlebar").hide();
  197. $("a.CloseBtn").on('click', function(){
  198. $("#NoticePopupBox" ).dialog("close");
  199. });
  200. $("#cancel_switch").on('click', function(){
  201. $("#NoticePopupBox" ).dialog("close");
  202. });
  203. $("#switch_homework_type_notice").text("您的作业类型将改为“编程作业”,并且您的分组设置将被清除。请问是否继续?");
  204. }
  205. else {
  206. $("#BluePopupBox").dialog("open");
  207. $(".ui-dialog-titlebar").hide();
  208. $("a.CloseBtn").on('click', function(){
  209. $("#BluePopupBox" ).dialog("close");
  210. });
  211. var inputs = document.getElementsByName("program[input][]");
  212. var outputs = document.getElementsByName("program[output][]");
  213. if (inputs.length == outputs.length) {
  214. for (var i=0; i<inputs.length; i++) {
  215. autoTextarea2(inputs[i], outputs[i]);
  216. autoTextarea2(outputs[i], inputs[i]);
  217. }
  218. }
  219. $(inputs[0]).focus();
  220. }
  221. });
  222. var saveProgramAnswers = function() {
  223. var test_numbers = 0;
  224. var valid = true;
  225. var input = null;
  226. var output = null;
  227. var input_groups = [];
  228. $.each($('#BluePopupBox textarea.InputBox'), function(i, val){
  229. if ($(val).val().length<=0) {
  230. $(val)[0].focus();
  231. valid =false;
  232. return false;
  233. }
  234. if (test_numbers %2==0) {
  235. input = $(val).val();
  236. } else {
  237. output = $(val).val();
  238. input_groups.push({input: input, output: output});
  239. }
  240. test_numbers += 1;
  241. });
  242. var language = '';
  243. if($('select.language_type').val() == 1){
  244. language = 'C';
  245. }else if($('select.language_type').val() == 2){
  246. language = 'C++';
  247. }else if($('select.language_type').val() == 3){
  248. language = 'Python';
  249. }else if($('select.language_type').val() == 4){
  250. language = 'Java';
  251. }
  252. if (valid) {
  253. $("input[name=homework_type]").val(2);
  254. $('span.program_detail_info').text('('+language+'语言,'+test_numbers/2+'组测试)');
  255. $("span.program_detail_info").addClass("fontBlue2");
  256. $("#program_setting a").addClass("fontBlue2");
  257. //保存js值
  258. var data = {
  259. language_type: $('select.language_type').val(),
  260. input_groups: input_groups
  261. };
  262. //构建到form中
  263. $('.program-input').remove();
  264. var html=bt('t:program-input-list',data);
  265. $("input[name=homework_type]").after(html);
  266. }
  267. return valid;
  268. };
  269. $("#BluePopupBox a.BlueCirBtn").live('click', function(){
  270. if(saveProgramAnswers()){
  271. if($( "#BluePopupBox" ).dialog( "isOpen" )){
  272. $("#BluePopupBox").dialog( "close" );
  273. }
  274. }
  275. });
  276. $("#BluePopupBox").on('click', 'a.icon_add', function(){
  277. var html = bt('t:test-answer-list', null);
  278. $(this).parent('.mt10').after(html);
  279. var inputs = document.getElementsByName("program[input][]");
  280. var outputs = document.getElementsByName("program[output][]");
  281. var inputs_labels = document.getElementsByName("inputs_label");
  282. for(var j= 0; j<inputs_labels.length; j++){
  283. $(inputs_labels[j]).html(j + 1 + "&nbsp;&nbsp;" );
  284. }
  285. if (inputs.length == outputs.length) {
  286. for (var i=0; i<inputs.length; i++) {
  287. autoTextarea2(inputs[i], outputs[i]);
  288. autoTextarea2(outputs[i], inputs[i]);
  289. }
  290. }
  291. $(inputs[inputs.length - 1]).focus();
  292. });
  293. $("#BluePopupBox").on('click', 'a.icon_remove', function(){
  294. $(this).parent('.mt10').remove();
  295. });
  296. //分组作业
  297. $("#GroupPopupBox").dialog({
  298. modal: true,
  299. autoOpen: false,
  300. dialogClass: 'BluePopupBox',
  301. minWidth: 290
  302. });
  303. $('#GroupPopupBox').parent().resizable("disable");
  304. $('#GroupPopupBox').parent().removeClass("ui-state-disabled");
  305. $('#GroupPopupBox').parent().css("border","3px solid #269ac9").css("padding","10px");
  306. $('a.groupBtn').live('click', function(){
  307. if($("input[name=homework_type]").val() == "2"){
  308. $("#NoticePopupBox").dialog("open");
  309. $(".ui-dialog-titlebar").hide();
  310. $("a.CloseBtn").on('click', function(){
  311. $("#NoticePopupBox" ).dialog("close");
  312. });
  313. $("#cancel_switch").on('click', function(){
  314. $("#NoticePopupBox" ).dialog("close");
  315. });
  316. $("#switch_homework_type_notice").text("您的作业类型将改为“分组作业”,并且您的编程设置将被清除。请问是否继续?");
  317. }
  318. else {
  319. $("#GroupPopupBox").dialog("open");
  320. $(".ui-dialog-titlebar").hide();
  321. $("a.popClose").on('click', function () {
  322. reset_group_attr();
  323. $("#GroupPopupBox").dialog("close");
  324. });
  325. $("#cancel_group").on('click', function () {
  326. reset_group_attr();
  327. $("#GroupPopupBox").dialog("close");
  328. });
  329. $('#min_num').focus();
  330. }
  331. });
  332. var reset_group_attr = function() {
  333. $("#min_num_notice").hide();
  334. $("#min_max_num_notice").hide();
  335. $("#max_num_notice").hide();
  336. if($("input[name=min_num]").length > 0 && $("input[name=max_num]").length > 0) {
  337. $("#min_num").val($("input[name=min_num]").val());
  338. $("#max_num").val($("input[name=max_num]").val());
  339. } else {
  340. $("#min_num").val(2);
  341. $("#max_num").val(10);
  342. }
  343. };
  344. var saveGroupAttr = function() {
  345. var valid = true;
  346. var base_on_project = 0;
  347. var min = $.trim($("#min_num").val());
  348. var max = $.trim($("#max_num").val());
  349. var regex = /^\d+$/;
  350. if(!regex.test(min) || parseInt(min) <= 0) {
  351. $("#min_num_notice").html("请输入正整数");
  352. $("#max_num_notice").html("");
  353. $("#min_max_num_notice").html("");
  354. $("#min_num_notice").show();
  355. $("#min_num").focus();
  356. return false;
  357. } else {
  358. $("#min_num_notice").html("");
  359. $("#min_num_notice").hide();
  360. }
  361. if(!regex.test(max) || parseInt(max) <= 0) {
  362. $("#max_num_notice").html("请输入正整数");
  363. $("#min_num_notice").html("");
  364. $("#min_max_num_notice").html("");
  365. $("#max_num_notice").show();
  366. $("#max_num").focus();
  367. return false;
  368. } else {
  369. $("#max_num_notice").html("");
  370. $("#max_num_notice").hide();
  371. }
  372. if(parseInt(min) > parseInt(max)) {
  373. $("#min_max_num_notice").html("最小人数不得大于最大人数");
  374. $("#min_num_notice").html("");
  375. $("#max_num_notice").html("");
  376. $("#min_max_num_notice").show();
  377. $("#max_num").focus();
  378. return false;
  379. } else {
  380. $("#min_max_num_notice").html("");
  381. $("#min_max_num_notice").hide();
  382. }
  383. if ($("#base_on_project").is(":checked")) {
  384. base_on_project = 1;
  385. }
  386. if (valid) {
  387. $("input[name=homework_type]").val(3);
  388. $('span.group_detail_info').text('分组人数:'+min+'-'+max+' 人');
  389. $("#group_setting a").addClass("fontBlue2");
  390. //保存js值
  391. var data = {
  392. base_on_project: base_on_project,
  393. min_num: min,
  394. max_num: max
  395. };
  396. //构建到form中
  397. $('.group-input').remove();
  398. var html=bt('t:group-input-list',data);
  399. $("input[name=homework_type]").after(html);
  400. }
  401. return valid;
  402. };
  403. $("#GroupPopupBox a.group_save_btn").live('click', function(){
  404. if(saveGroupAttr()){
  405. if($( "#GroupPopupBox" ).dialog( "isOpen" )){
  406. $("#GroupPopupBox").dialog( "close" );
  407. }
  408. }
  409. });
  410. //代码编辑器
  411. if (typeof CodeMirror != "undefined") {
  412. var program_name = "text/x-csrc";
  413. var language = $('#data-language').attr('data-language');
  414. if (language == 1) {
  415. program_name = 'text/x-csrc';
  416. } else if(language==2){
  417. program_name = 'text/x-c++src';
  418. }else if(language==3){
  419. program_name = 'text/x-cython';
  420. } else if(language==4){
  421. program_name = 'text/x-java';
  422. }
  423. if ($('#program-src').val().length<=0) {
  424. var src = '';
  425. if(language==4){
  426. src = '\
  427. //注意\n\
  428. //1:该程序每次运行的时间必须小于200毫秒,否则会超时,程序超时将不会测试剩余的测试集\n\
  429. //2:该程序每次运行使用的内存不能超过1M,否则会返回错误\n\
  430. //3:该程序每次运行输出的结果最多显示100个字符(多余的不显示),每行末尾的所有空格用□表示\n\
  431. import java.io.*;\n\
  432. import java.util.*;\n\
  433. \n\
  434. //请一定不要修改类名\n\
  435. class Main\n\
  436. {\n\
  437. public static void main (String args[])\n\
  438. {\n\
  439. //获取参数方式\n\
  440. //Scanner in = new Scanner(System.in);\n\
  441. //int a = in.nextInt();\n\
  442. //int b = in.nextInt();\n\
  443. \n\
  444. //您的代码\n\
  445. }\n\
  446. }\n\
  447. ';
  448. }
  449. else if(language==1){
  450. src = '\
  451. //注意\n\
  452. //1:该程序每次运行的时间必须小于200毫秒,否则会超时,程序超时将不会测试剩余的测试集\n\
  453. //2:该程序每次运行使用的内存不能超过1M,否则会返回错误\n\
  454. //3:该程序每次运行输出的结果最多显示100个字符(多余的不显示),每行末尾的所有空格用□表示\n\
  455. #include <stdio.h>\n\
  456. int main()\n\
  457. {\n\
  458. //获取参数方式 scanf\n\
  459. //int x =0;\n\
  460. //int y = 0;\n\
  461. //scanf("%d", &x);\n\
  462. \n\
  463. //结果输出使用prinf\n\
  464. //printf("%d",x);\n\
  465. \n\
  466. return 0;\n\
  467. }\n\
  468. ';
  469. } else if(language==2){
  470. src = '\
  471. //注意\n\
  472. //1:该程序每次运行的时间必须小于200毫秒,否则会超时,程序超时将不会测试剩余的测试集\n\
  473. //2:该程序每次运行使用的内存不能超过1M,否则会返回错误\n\
  474. //3:该程序每次运行输出的结果最多显示100个字符(多余的不显示),每行末尾的所有空格用□表示\n\
  475. #include <iostream>\n\
  476. using namespace std;\n\
  477. \n\
  478. int main()\n\
  479. {\n\
  480. //获取参数方式 cin\n\
  481. //int x =0;\n\
  482. //cin >> x;\n\
  483. \n\
  484. //结果输出使用 cout\n\
  485. //cout<<"1";\n\
  486. \n\
  487. return 0;\n\
  488. }\n\
  489. ';
  490. } else if(language==3){
  491. src = '\
  492. #-*-coding:utf-8-*-\n\
  493. #注意\n\
  494. #1:该程序每次运行的时间必须小于200毫秒,否则会超时,程序超时将不会测试剩余的测试集\n\
  495. #2:该程序每次运行使用的内存不能超过1M,否则会返回错误\n\
  496. #3:该程序每次运行输出的结果最多显示100个字符(多余的不显示),空格用□表示\n\
  497. import sys \n\
  498. \n\
  499. #获取参数方式,使用raw_input\n\
  500. #input = raw_input()\n\
  501. #a, b = input.split()\n\
  502. \n\
  503. #结果输出使用 print \n\
  504. #print (str(int(a)+int(b)))\n\
  505. ';
  506. }
  507. $('#program-src').val(src);
  508. };
  509. var editor = CodeMirror.fromTextArea(document.getElementById("program-src"), {
  510. mode: {name: program_name,
  511. version: 2,
  512. singleLineStringErrors: false},
  513. lineNumbers: true,
  514. indentUnit: 2,
  515. matchBrackets: true
  516. });
  517. editor.on('change',function(cMirror){
  518. // get value right from instance
  519. $('#program-src').val(cMirror.getValue());
  520. });
  521. }
  522. });

软件技术创新是当今国家整体创新能力的重要基础和发展引擎。近年来,大众参与的软件创新与创业活动已经成为网络时代软件开发和应用的新形态,正在快速改变着全球软件创新模式和软件产业格局。 ...