Open main menu

Biolecture.org β

Changes

Ilsun Yun/Homework2/SourceCode

3,588 bytes added, 03:36, 1 December 2018
Created page with "<p>#include<iostream><br /> #include <vector><br /> #include <algorithm></p> <p>using namespace std;<br /> vector<int> output;</p> <p>int check(int arr[..."
<p>#include&lt;iostream&gt;<br />
#include &lt;vector&gt;<br />
#include &lt;algorithm&gt;</p>

<p>using namespace std;<br />
vector&lt;int&gt; output;</p>

<p>int check(int arr[25][25]){<br />
&nbsp;&nbsp; &nbsp;<br />
&nbsp;&nbsp; &nbsp;for(int i=0;i&lt;25;i++){<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;for(int j=0;j&lt;25;j++){<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if(arr[i][j]&gt;0){<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if(arr[i+1][j+1]==1){<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;arr[i+1][j+1]=arr[i+1][j+1]+arr[i][j];<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;arr[i][j]=0;<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}&nbsp;&nbsp; &nbsp;<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br />
&nbsp;&nbsp; &nbsp;}<br />
&nbsp;&nbsp; &nbsp;return arr[25][25];<br />
}</p>

<p>int main()<br />
{<br />
&nbsp;&nbsp; &nbsp;string sample1 = &quot;AAGAATAGTATTTCGCTTTTTTATA&quot;;<br />
&nbsp;&nbsp; &nbsp;string sample2 = &quot;AGAAATAGTATTTCGGTTAATTATA&quot;;<br />
&nbsp;&nbsp; &nbsp;int samparray[25][25];<br />
&nbsp;&nbsp; &nbsp;for(int i=0;i&lt;25;i++){<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;for(int j=0;j&lt;25;j++){<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if(sample1[i]==sample2[j]){<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;samparray[i][j]=1;<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} else {<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;samparray[i][j]=0;<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}</p>

<p>&nbsp;&nbsp; &nbsp;}<br />
&nbsp;&nbsp; &nbsp;check(samparray);<br />
&nbsp;&nbsp; &nbsp;<br />
&nbsp;&nbsp; &nbsp;for(int i=0;i&lt;25;i++){&nbsp;&nbsp; &nbsp;<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;for(int j=0;j&lt;25;j++){<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;cout&lt;&lt;samparray[i][j]&lt;&lt;&quot; &quot;;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;cout &lt;&lt;endl;<br />
&nbsp;&nbsp; &nbsp;}<br />
&nbsp;&nbsp; &nbsp;cout &lt;&lt;&quot;The contigs sorting...&quot; &lt;&lt; endl;<br />
&nbsp;&nbsp; &nbsp;<br />
&nbsp;&nbsp; &nbsp;for(int i=0;i&lt;25;i++){<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;for(int j=0;j&lt;25;j++){<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if(samparray[i][j]&gt;0){<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;int a = samparray[i][j];<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;output.push_back(a);<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}&nbsp;&nbsp; &nbsp;<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br />
&nbsp;&nbsp; &nbsp;}&nbsp;&nbsp; &nbsp;<br />
&nbsp;&nbsp; &nbsp;<br />
&nbsp;&nbsp; &nbsp;sort(output.begin(),output.end());<br />
&nbsp;&nbsp; &nbsp;for(int i=output.size()-1;i&gt;=0;i--){<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;cout&lt;&lt;output[i]&lt;&lt;endl;<br />
&nbsp;&nbsp; &nbsp;}<br />
&nbsp;&nbsp; &nbsp;</p>

<p>}<br />
&nbsp;</p>
Anonymous user