免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 922 | 回复: 0

chen_pen_16to10 [复制链接]

论坛徽章:
0
发表于 2011-12-22 08:52 |显示全部楼层
<DIV>
<DIV class=codeText id=codeText>
<OL class=dp-css style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 5px; MARGIN: 0px 1px 0px 0px; PADDING-TOP: 5px">
<LI><SPAN style="COLOR: #000000"><SPAN style="COLOR: #0000cc">/</SPAN><SPAN style="COLOR: #0000cc">/</SPAN> 16to10<SPAN style="COLOR: #0000cc">.</SPAN>cpp <SPAN style="COLOR: #0000cc">:</SPAN> Defines the entry point <SPAN style="COLOR: #0000ff">for</SPAN> the console application<SPAN style="COLOR: #0000cc">.</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">/</SPAN><SPAN style="COLOR: #0000cc">/</SPAN><BR></LI>
<LI><BR></LI>
<LI>#include <SPAN style="COLOR: #ff00ff">"stdafx.h"</SPAN><BR></LI>
<LI>#include <SPAN style="COLOR: #0000cc">&lt;</SPAN>iostream<SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI>#include <SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #ff0000">string</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI>#include <SPAN style="COLOR: #0000cc">&lt;</SPAN>ctype<SPAN style="COLOR: #0000cc">.</SPAN>h<SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI><BR></LI>
<LI>using namespace std<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><BR></LI>
<LI><SPAN style="COLOR: #ff0000">int</SPAN> _16to10<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #ff0000">string</SPAN> content<SPAN style="COLOR: #0000cc">)</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">int</SPAN> sum<SPAN style="COLOR: #0000cc">=</SPAN>0<SPAN style="COLOR: #0000cc">,</SPAN>fact<SPAN style="COLOR: #0000cc">=</SPAN>1<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">for</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #ff0000">int</SPAN> i<SPAN style="COLOR: #0000cc">=</SPAN>content<SPAN style="COLOR: #0000cc">.</SPAN>size<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">-</SPAN>1<SPAN style="COLOR: #0000cc">;</SPAN>i<SPAN style="COLOR: #0000cc">&gt;</SPAN><SPAN style="COLOR: #0000cc">=</SPAN>0<SPAN style="COLOR: #0000cc">;</SPAN>i<SPAN style="COLOR: #0000cc">-</SPAN><SPAN style="COLOR: #0000cc">-</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;char c<SPAN style="COLOR: #0000cc">=</SPAN>content<SPAN style="COLOR: #0000cc">[</SPAN>i<SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #0000cc">(</SPAN>isdigit<SPAN style="COLOR: #0000cc">(</SPAN>c<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sum<SPAN style="COLOR: #0000cc">+</SPAN><SPAN style="COLOR: #0000cc">=</SPAN>fact<SPAN style="COLOR: #0000cc">*</SPAN><SPAN style="COLOR: #0000cc">(</SPAN>c<SPAN style="COLOR: #0000cc">-</SPAN><SPAN style="COLOR: #0000cc">'</SPAN>0<SPAN style="COLOR: #0000cc">'</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">else</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">int</SPAN> result<SPAN style="COLOR: #0000cc">=</SPAN>tolower<SPAN style="COLOR: #0000cc">(</SPAN>c<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sum<SPAN style="COLOR: #0000cc">+</SPAN><SPAN style="COLOR: #0000cc">=</SPAN>fact<SPAN style="COLOR: #0000cc">*</SPAN><SPAN style="COLOR: #0000cc">(</SPAN>result<SPAN style="COLOR: #0000cc">-</SPAN><SPAN style="COLOR: #0000cc">'</SPAN>a<SPAN style="COLOR: #0000cc">'</SPAN><SPAN style="COLOR: #0000cc">+</SPAN>10<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fact<SPAN style="COLOR: #0000cc">*</SPAN><SPAN style="COLOR: #0000cc">=</SPAN>16<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;return sum<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI><BR></LI>
<LI><SPAN style="COLOR: #ff0000">int</SPAN> main<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #ff0000">int</SPAN> argc<SPAN style="COLOR: #0000cc">,</SPAN> char<SPAN style="COLOR: #0000cc">*</SPAN> argv<SPAN style="COLOR: #0000cc">[</SPAN><SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">string</SPAN> content<SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"B0"</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">int</SPAN> result<SPAN style="COLOR: #0000cc">=</SPAN>_16to10<SPAN style="COLOR: #0000cc">(</SPAN>content<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;cout<SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000cc">&lt;</SPAN>result<SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000cc">&lt;</SPAN>endl<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;return 0<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">}</SPAN></SPAN></LI></OL></DIV></DIV>
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

DTCC2020中国数据库技术大会 限时9.5折

【架构革新 高效可控】2020年8月17日~19日第十一届中国数据库技术大会将在北京隆重召开。

大会设置2大主会场,20+技术专场,将邀请超百位行业专家,重点围绕数据架构、AI与大数据、传统企业数据库实践和国产开源数据库等内容展开分享和探讨,为广大数据领域从业人士提供一场年度盛会和交流平台。

http://dtcc.it168.com


大会官网>>
  

北京盛拓优讯信息技术有限公司. 版权所有 16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122
中国互联网协会会员  联系我们:huangweiwei@it168.com
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP