<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/">
<channel>
    <title>c语言 求1+2+3+...+100的值 - Code666 (代码贴、代码片段)</title>
    <description>c语言 求1+2+3+...+100的值 - Code666 (代码贴、代码片段)</description>
    <atom:link href="http://www.code666.cn/view/rss/1a7b7b5b" rel="self" type="application/rss+xml" />
    <link>http://www.code666.cn/</link>
    <language>en</language>
<item>
    <title>Re: c语言 求1+2+3+...+100的值</title>
    <link>http://www.code666.cn/view/55c7bb3a</link>
    <pubDate>Wed, 17 Apr 2024 23:56:32 +0800</pubDate>
    <dc:creator>Aqua Partdridge</dc:creator>
    <guid isPermaLink="false">http://www.code666.cn/view/55c7bb3a</guid>
    <description><![CDATA[#include &lt;stdio.h&gt; int main(){ int a,sum; //定义变量 a=1,sum=0; //赋初值 do{ // do···while循环，先执行循环体 sum+=a; //sum=sum+a a++; //a+1 }while(a&lt;=100); //检查条件是否成立 printf(&quot;sum=%d&quot;,sum); //输出sum&#8230;]]></description>
    <content:encoded><![CDATA[<div class="c" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #339933;">#include &lt;stdio.h&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #993333;">int</span> a<span style="color: #339933;">,</span>sum<span style="color: #339933;">;</span> &nbsp;<span style="color: #666666; font-style: italic;">//定义变量</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; a<span style="color: #339933;">=</span><span class="nu0">1</span><span style="color: #339933;">,</span>sum<span style="color: #339933;">=</span><span class="nu0">0</span><span style="color: #339933;">;</span> &nbsp;<span style="color: #666666; font-style: italic;">//赋初值</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #b1b100;">do</span><span style="color: #009900;">&#123;</span> &nbsp;<span style="color: #666666; font-style: italic;">// do···while循环，先执行循环体</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; sum<span style="color: #339933;">+=</span>a<span style="color: #339933;">;</span> &nbsp;<span style="color: #666666; font-style: italic;">//sum=sum+a</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; a<span style="color: #339933;">++;</span> &nbsp;<span style="color: #666666; font-style: italic;">//a+1</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span>a<span style="color: #339933;">&lt;=</span><span class="nu0">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp;<span style="color: #666666; font-style: italic;">//检查条件是否成立</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;sum=%d&quot;</span><span style="color: #339933;">,</span>sum<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp;<span style="color: #666666; font-style: italic;">//输出sum</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span class="nu0">0</span><span style="color: #339933;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
</ol></div>]]></content:encoded>
</item>
</channel>
</rss>
