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 24 kB

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

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