Skip to content

Commit

Permalink
Updated post(20241005_171213)
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueBoy247 authored Oct 30, 2024
1 parent 9c6ad3c commit 8a59f0a
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion archives/20241005_171213/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,30 @@ <h3 class="zhwb" id="參考解答">參考解答</h3>
</div>
<div class="tab-content active" id="c-code">
<pre><code class="c">

#include &lt;stdio.h&gt;
int tripleNPlusOne(int n){
int count = 1;
while(n!=1){
if(n%2==0) n/=2;
else n=n*3+1;
count++;
}
return count;
}
void main(){
int i,j,temp_i,temp_j,max;
while(scanf("%d %d",&i,&j) != EOF){
max=0;
temp_i = i>j ? j : i;
temp_j = i>j ? i : j;
for(int k=temp_i;k<=temp_j;k++){
int count = tripleNPlusOne(k);
if(count>max) max=count;
}
printf("%d %d %d\n",i,j,max);
}
return;
}
</code></pre>
<script>hljs.initHighlightingOnLoad();</script>
</div>
Expand Down

0 comments on commit 8a59f0a

Please sign in to comment.