{"action":"created","issue":{"url":"https://api.github.com/repos/ShaoGroup/Intro2CompBio/issues/12","labels_url":"https://api.github.com/repos/ShaoGroup/Intro2CompBio/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/ShaoGroup/Intro2CompBio/issues/12/comments","events_url":"https://api.github.com/repos/ShaoGroup/Intro2CompBio/issues/12/events","html_url":"https://github.com/ShaoGroup/Intro2CompBio/pull/12","id":117565737,"number":12,"title":"赵沛霖（2012011513）的程序代码，本来想upload个txt，奈何上传实在太慢……","user":{"login":"rayzhao94","id":15901541,"avatar_url":"https://avatars.githubusercontent.com/u/15901541?v=3","gravatar_id":"","url":"https://api.github.com/users/rayzhao94","html_url":"https://github.com/rayzhao94","followers_url":"https://api.github.com/users/rayzhao94/followers","following_url":"https://api.github.com/users/rayzhao94/following{/other_user}","gists_url":"https://api.github.com/users/rayzhao94/gists{/gist_id}","starred_url":"https://api.github.com/users/rayzhao94/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rayzhao94/subscriptions","organizations_url":"https://api.github.com/users/rayzhao94/orgs","repos_url":"https://api.github.com/users/rayzhao94/repos","events_url":"https://api.github.com/users/rayzhao94/events{/privacy}","received_events_url":"https://api.github.com/users/rayzhao94/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-18T11:16:40Z","updated_at":"2015-11-18T11:18:21Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ShaoGroup/Intro2CompBio/pulls/12","html_url":"https://github.com/ShaoGroup/Intro2CompBio/pull/12","diff_url":"https://github.com/ShaoGroup/Intro2CompBio/pull/12.diff","patch_url":"https://github.com/ShaoGroup/Intro2CompBio/pull/12.patch"},"body":"using namespace std;\r\n#include <stdio.h>\r\n#include<stdlib.h>\r\n#include<fstream>\r\n#include <iostream>\r\n#define N 10000\r\nstruct matrix_ \r\n{\r\n\tint length;\r\n\tint indicator;\r\n};\r\nchar s1[N + 5];\r\nchar s2[N + 5];\r\nchar storage_result[N + 5];\r\nstruct matrix_ matrix_st[N + 5][N + 5];\r\nint result_st[N + 5][N + 5] = { 0 };\r\nint calculator(char s1[N + 5], char s2[N + 5], int alpha, int beta, int gamma)\r\n{\r\n\tint maxresult = 0,i, j, k, len1, len2, count;\r\n\tint result = 0;\r\n\tint length_s1 = strlen(s1);\r\n\tint length_s2 = strlen(s2);\r\n\r\n\r\n\tfor (i = 0; s1[i] != '\\0'; i++)\r\n\t{\r\n\t\tfor (j = 0; s2[j] != '\\0'; j++)\r\n\t\t{\r\n\t\t\tif (s1[i] == s2[j])\r\n\t\t\t{\r\n\t\t\t\tmatrix_st[i + 1][j + 1].length = matrix_st[i][j].length + 1;\r\n\t\t\t\tmatrix_st[i + 1][j + 1].indicator = 1;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tif (matrix_st[i][j + 1].length > matrix_st[i + 1][j].length)\r\n\t\t\t\t{\r\n\t\t\t\t\tmatrix_st[i + 1][j + 1].length = matrix_st[i][j + 1].length;\r\n\t\t\t\t\tmatrix_st[i + 1][j + 1].indicator = 3;\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tmatrix_st[i + 1][j + 1].length = matrix_st[i + 1][j].length;\r\n\t\t\t\t\tmatrix_st[i + 1][j + 1].indicator = 2;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tlen1 = i;\r\n\tlen2 = j;\r\n\tint length = matrix_st[len1][len2].length;\r\n\tfor (k = length - 1; k >= 0;)\r\n\t{\r\n\t\tif (matrix_st[i][j].indicator == 1)\r\n\t\t{\r\n\t\t\tstorage_result[k] = s1[i - 1];\r\n\t\t\tk--;\r\n\t\t\ti--;\r\n\t\t\tj--;\r\n\t\t}\r\n\t\telse if (matrix_st[i][j].indicator == 2)\r\n\t\t{\r\n\t\t\tj--;\r\n\t\t}\r\n\t\telse if (matrix_st[i][j].indicator == 3)\r\n\t\t{\r\n\t\t\ti--;\r\n\t\t}\r\n\t}\r\n\tfor (k = 0; k < length; k++)\r\n\t{\r\n\t\tprintf(\"%c\", storage_result[k]);\r\n\t}\r\n\tputs(\"\");\r\n\r\n\tfor (i = 1; i<length_s1; i++) { result_st[i][0] = -i*gamma; }\r\n\tfor (j = 1; j<length_s2; j++) { result_st[0][j] = -j*gamma; }\r\n\r\n\tint a, b, c;\r\n\tfor (i = 1; i<length_s1; i++)\r\n\t{\r\n\t\tfor (j = 1; j<length_s2; j++)\r\n\t\t{\r\n\t\t\tif (s1[i - 1] == s2[j - 1])\r\n\t\t\t\ta = result_st[i - 1][j - 1] + alpha;\r\n\t\t\telse { a = result_st[i - 1][j - 1] - beta; }\r\n\t\t\tb = result_st[i][j - 1] - gamma;\r\n\t\t\tc = result_st[i - 1][j] - gamma;\r\n\r\n\t\t\tif (a >= b&&a >= c)\r\n\t\t\t\tresult_st[i][j] = a;\r\n\t\t\telse if (b >= a&&b >= c)\r\n\t\t\t\tresult_st[i][j] = b;\r\n\t\t\telse if (c >= a&&c >= a)\r\n\t\t\t\tresult_st[i][j] = c;\r\n\t\t}\r\n\t}\r\n\r\n\tint temp1 = 0, temp2 = 0;\r\n\r\n\tfor (i = 0; i<length_s1; i++) {\r\n\t\tfor (j = 0; j<length_s2; j++) {\r\n\t\t\tif (result_st[i][j]>maxresult) {\r\n\t\t\t\tmaxresult = result_st[i][j];\r\n\t\t\t\ttemp1 = i;\r\n\t\t\t\ttemp2 = j;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn maxresult;\r\n}\r\n\r\n\r\n\r\nvoid main()//此处参考了部分网络代码，进行修改后使用，在此声明！\r\n{//复杂度为n^2\r\n\tint alpha = 1, beta = 0, gamma = 0;\r\n\tint answer;\r\n\tifstream zplfile;\r\n\r\n\tzplfile.open(\"E:\\\\LongestCommonSeq.txt\", ios::in);\r\n\t//zplfile >> s1;\r\n\t//zplfile >> s2;\r\n\tzplfile.getline(s1, N + 5);\r\n\tzplfile.getline(s2, N + 5);\r\n\tanswer = calculator(s1, s2, alpha, beta, gamma);\r\n\tprintf(\"%d\\n\", answer);\r\n\r\n\tsystem(\"pause\");\r\n}"},"comment":{"url":"https://api.github.com/repos/ShaoGroup/Intro2CompBio/issues/comments/157682243","html_url":"https://github.com/ShaoGroup/Intro2CompBio/pull/12#issuecomment-157682243","issue_url":"https://api.github.com/repos/ShaoGroup/Intro2CompBio/issues/12","id":157682243,"user":{"login":"rayzhao94","id":15901541,"avatar_url":"https://avatars.githubusercontent.com/u/15901541?v=3","gravatar_id":"","url":"https://api.github.com/users/rayzhao94","html_url":"https://github.com/rayzhao94","followers_url":"https://api.github.com/users/rayzhao94/followers","following_url":"https://api.github.com/users/rayzhao94/following{/other_user}","gists_url":"https://api.github.com/users/rayzhao94/gists{/gist_id}","starred_url":"https://api.github.com/users/rayzhao94/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rayzhao94/subscriptions","organizations_url":"https://api.github.com/users/rayzhao94/orgs","repos_url":"https://api.github.com/users/rayzhao94/repos","events_url":"https://api.github.com/users/rayzhao94/events{/privacy}","received_events_url":"https://api.github.com/users/rayzhao94/received_events","type":"User","site_admin":false},"created_at":"2015-11-18T11:18:21Z","updated_at":"2015-11-18T11:18:21Z","body":"![123](https://cloud.githubusercontent.com/assets/15901541/11239787/7bf054ac-8e31-11e5-8031-f40431b5dc49.png)\r\n"}}