本文主要是介绍1018:奇怪的信,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
<h1 style="padding: 10px 0px 0px; margin: 0px; clear: both; font-family: 'Microsoft Yahei'; background-color: rgb(245, 245, 245);">1018:奇怪的信<span class="y" style="padding: 0px; margin: 0px; float: right;">分数: 10</span></h1><div class="infolist" style="padding: 0px 0px 5px; margin: 20px 0px 10px; width: 1002px; border-bottom-width: 2px; border-bottom-style: solid; border-bottom-color: rgb(187, 187, 187); overflow: hidden; font-family: 'Microsoft Yahei'; font-size: 14px; background-color: rgb(245, 245, 245);"><div style="padding: 3px; margin: 0px 10px 0px 0px; width: 184px; border: 1px solid rgb(204, 204, 204); float: left; background: rgb(238, 238, 238);"><span style="padding: 0px; margin: 0px;">时间限制:</span>1 秒</div><div style="padding: 3px; margin: 0px 10px 0px 0px; width: 184px; border: 1px solid rgb(204, 204, 204); float: left; background: rgb(238, 238, 238);"><span style="padding: 0px; margin: 0px;">内存限制:</span>32 兆</div><div style="padding: 3px; margin: 0px 10px 0px 0px; width: 184px; border: 1px solid rgb(204, 204, 204); float: left; background: rgb(238, 238, 238);"><span style="padding: 0px; margin: 0px;">特殊判题:</span> 否</div><div style="padding: 3px; margin: 0px 10px 0px 0px; width: 184px; border: 1px solid rgb(204, 204, 204); float: left; background: rgb(238, 238, 238);"><span style="padding: 0px; margin: 0px;">提交:</span>50</div><div class="end" style="padding: 3px; margin: 0px; width: 184px; border: 1px solid rgb(204, 204, 204); float: right; background: rgb(238, 238, 238);"><span style="padding: 0px; margin: 0px;">解决:</span> 30</div></div><div id="leftinfo" style="padding: 0px; margin: 0px; font-family: 'Microsoft Yahei'; font-size: 14px; background-color: rgb(245, 245, 245);"><div id="lbox" style="padding: 0px; margin: 0px; line-height: 2;"><h3 style="padding: 0px; margin: 0px;">标签</h3><div class="tptag" style="padding: 10px 0px; margin: 0px; width: 1002px; overflow: hidden; background: rgb(238, 238, 238);"><ul style="padding: 0px; margin: 0px; list-style: none;"><li style="padding: 1px 10px; margin: 0px 10px; float: left; color: rgb(151, 124, 14); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background: rgb(255, 252, 201);">简单题</li></ul></div><h3 style="padding: 0px; margin: 0px;">题目描述</h3><p style="padding-top: 0px; padding-bottom: 0px; margin-top: 0px; margin-bottom: 0px;">有一天, 小明收到一张奇怪的信, 信上要小明计算出给定数各个位上数字为偶数的和。<br style="padding: 0px; margin: 0px;" />例如:5548,结果为12,等于 4 + 8 。<br style="padding: 0px; margin: 0px;" />小明很苦恼,想请你帮忙解决这个问题。<br style="padding: 0px; margin: 0px;" /></p><h3 style="padding: 0px; margin: 0px;">输入格式</h3><p style="padding-top: 0px; padding-bottom: 0px; margin-top: 0px; margin-bottom: 0px;">输入数据有多组。每组占一行,只有一个整整数,保证数字在32位整型范围内。</p><h3 style="padding: 0px; margin: 0px;">输出</h3><p style="padding-top: 0px; padding-bottom: 0px; margin-top: 0px; margin-bottom: 0px;">对于每组输入数据,输出一行,每两组数据之间有一个空行。</p><h3 style="padding: 0px; margin: 0px;">样例输入</h3><p style="padding-top: 0px; padding-bottom: 0px; margin-top: 0px; margin-bottom: 0px;"><span style="padding: 0px; margin: 0px; font-family: 'Lucida Console';">415326<br style="padding: 0px; margin: 0px;" />3262</span></p><h3 style="padding: 0px; margin: 0px;">样例输出</h3><p style="padding-top: 0px; padding-bottom: 0px; margin-top: 0px; margin-bottom: 0px;"><span style="padding: 0px; margin: 0px; font-family: 'Lucida Console';">12<br style="padding: 0px; margin: 0px;" /><br style="padding: 0px; margin: 0px;" />10</span></p><span id="isyc" style="padding: 0px; margin: 0px;"></span><h3 style="padding: 0px; margin: 0px;"><div style="padding: 0px; margin: 0px; cursor: pointer;">提示[+]</div></h3><p style="padding-top: 0px; padding-bottom: 0px; margin-top: 0px; margin-bottom: 0px;">*** 提示已隐藏,点击上方 [+] 可显示 ***</p><h3 style="padding: 0px; margin: 0px;">分类</h3><div class="tptag" style="padding: 10px 0px; margin: 0px; width: 1002px; overflow: hidden; background: rgb(238, 238, 238);"><ul style="padding: 0px; margin: 0px; list-style: none;"><li style="padding: 1px 10px; margin: 0px 10px; float: left; color: rgb(151, 124, 14); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background: rgb(255, 252, 201);"><a target=_blank href="http://hznu.acmclub.com/index.php?app=problem_list&expanded=5072" style="padding: 0px; margin: 0px; text-decoration: none; color: rgb(151, 124, 14);">ACM入门题</a></li></ul></div></div></div>
#include<stdio.h>int main(){int N,i=0,sum=0;while(scanf("%d",&N)!=EOF){while(N!=0){if(N%10%2==0)sum+=N%10;N=N/10;}if(i++)printf("\n");//用这种方法做出两个数据间有空行 printf("%d\n",sum);//不能直接两个回车,因为最后一个数据后面不需要空行 sum=0;}}
这篇关于1018:奇怪的信的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!