<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>https://jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>https://jackxiang.com/post//</link>
<title><![CDATA[[实践OK]每日一问之有一个n位数，它的各位数字翻转以后组成新的n位数，原来的n位数是新n位数的n倍，求所有可能的n位数。]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[Php/Js/Shell/Go]]></category>
<pubDate>Tue, 27 Aug 2019 06:55:22 +0000</pubDate> 
<guid>https://jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	有一个n位数，它的各位数字翻转以后组成新的n位数，原来的n位数是新n位数的n倍，求所有可能的n位数。<br/>如：<br/>8712/4 = 2,178<br/><br/><br/>鸟哥的代码：<br/><textarea name="code" class="php" rows="15" cols="100">
#include &lt;stdio.h&gt;
#include &lt;stdint.h&gt;

static uint64_t revert(uint64_t n, int *width)
&#123;
 int i;
 char buf[64];
 uint64_t ret = 0, weight = 1;
 *width = sprintf(buf, &quot;%llu&quot;, (unsigned long long)n);
 for (i = 0; buf[i]; ++i) &#123;
&nbsp;&nbsp;ret += (buf[i] - &#039;0&#039;) * weight;
&nbsp;&nbsp;weight *= 10;
 &#125;
 return ret;
&#125;

int main()
&#123;
 int w;
 uint64_t n;

 for (n = 0; n &lt;= 200000000; ++n) &#123;
&nbsp;&nbsp;uint64_t r = revert(n, &amp;w);
&nbsp;&nbsp;if (r == n * w) &#123;
&nbsp;&nbsp; printf(&quot;%lld = %lld / %d&#92;n&quot;, (unsigned long long)n,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(unsigned long long)r, w);
&nbsp;&nbsp;&#125;
 &#125;
&#125;

</textarea><br/>#make calcnumber<br/>cc&nbsp;&nbsp;&nbsp;&nbsp; calcnumber.c&nbsp;&nbsp; -o calcnumber<br/><br/>#./calcnumber <br/>0 = 0 / 1<br/>1 = 1 / 1<br/>2 = 2 / 1<br/>3 = 3 / 1<br/>4 = 4 / 1<br/>5 = 5 / 1<br/>6 = 6 / 1<br/>7 = 7 / 1<br/>8 = 8 / 1<br/>9 = 9 / 1<br/>2178 = 8712 / 4<br/>108901089 = 980109801 / 9<br/>109999989 = 989999901 / 9<br/><br/><br/>http://live.aulddays.com/tech/11/linux-shell-too-great-base-error.htm<br/><br/><br/>我用shell写了一个：<br/>#cat *.sh<br/>#!/bin/bash<br/>for i in &#123;1000..9999&#125; ;do<br/>&nbsp;&nbsp;&nbsp;&nbsp;rev=$(echo $i &#124; rev)<br/>&nbsp;&nbsp;&nbsp;&nbsp;div=$(echo &quot;$rev/4&quot; &#124; bc)<br/>&nbsp;&nbsp;&nbsp;&nbsp;if [[ &quot;10#$i&quot; -eq &quot;10#$div&quot; ]];then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;result=&quot;$i;<br/>&nbsp;&nbsp;&nbsp;&nbsp;fi<br/>done<br/><br/>sh calcnumber.sh <br/>result=1997&nbsp;&nbsp;#这个是小数四舍五入后相等的，shell在处理小数这方面有些弱，得靠BC。<br/>result=2178
]]>
</description>
</item><item>
<link>https://jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] [实践OK]每日一问之有一个n位数，它的各位数字翻转以后组成新的n位数，原来的n位数是新n位数的n倍，求所有可能的n位数。]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>https://jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>