c75_31.htm

来自「经典c语言教程」· HTM 代码 · 共 53 行

HTM
53
字号
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>例子 </title>
<script language="javascript">
	function init(){
		out=outdiv.style;
	}

	function show(obj){
		obj.display='';
	}
</script>
</head>

<body bgcolor="#ccefcc" onLoad="init()">

<blockquote>
  <div align="center"><center><table border="6" width="420" cellspacing="0" cellpadding="6"
  height="150" bordercolor="#FF9933">
    <tr>
      <th width="644" bgcolor="#FF9933">程序</th>
    </tr>
    <tr>
      <td ALIGN="center" width="644" bgcolor="#00FFFF"><p align="left">int str_to_int(char 
      str[])<br>
      {<br>
      &nbsp;&nbsp;&nbsp; int i, int_value,result=0;<br>
      &nbsp;&nbsp;&nbsp; for (i=0; str[i] &gt;= '0' &amp;&amp; str[i] &lt;= '9'; ++i)<br>
      &nbsp;&nbsp;&nbsp; {<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int_value = str[i] - '0';<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; result = result*10 + int_value;<br>
      &nbsp;&nbsp;&nbsp; }<br>
      &nbsp;&nbsp;&nbsp; return(result);<br>
      }<br>
      main()<br>
      {<br>
      &nbsp;&nbsp;&nbsp; printf(&quot;%d\n&quot;,str_to_int(&quot;245&quot;));<br>
      &nbsp;&nbsp;&nbsp; printf(&quot;%d\n&quot;,str_to_int(&quot;100&quot;)+25);<br>
      &nbsp;&nbsp;&nbsp; printf(&quot;%d\n&quot;,str_to_int(&quot;13*5&quot;));<br>
      }</td>
    </tr>
  </table>
  </center></div><p><a href="javascript:show(out)">输出是什么</a>?</p>
  <div id="outdiv" style="display:'none'"><p>245<br>
  125<br>
  13</p>
  </div><p align="center"><a href="javascript:close()">关闭</a></p>
</blockquote>
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?