天涯人论坛
先登录吧!!!
登录可以体验更多权限哦!!!
天涯人论坛
先登录吧!!!
登录可以体验更多权限哦!!!
天涯人论坛
Would you like to react to this message? Create an account in a few clicks or log in to continue.
天涯人论坛

为编程爱好者打造一个学习、交流的平台。
 
首页首页  欢迎页欢迎页  Latest imagesLatest images  注册注册  登录登录  
论坛刚刚起步,欢迎大家多多支持! 如果有想申请管理员或版主的请给管理员留言!!!
欢迎大家积极发帖!

 

 【敲七】

向下 
作者留言
让一切随风
Admin
让一切随风


帖子数 : 257
注册日期 : 12-11-03
年龄 : 32
地点 : 湖南

【敲七】 Empty
帖子主题: 【敲七】   【敲七】 Empty周六 四月 20, 2013 8:55 pm

【敲七】



Time Limit:10000MS Memory Limit:65536K

Total Submit:765 Accepted:249



Description



输出77的倍数,还有包含7的数字例如(172737...70717273...





Input



一个整数N(N不大于30000)





Output



统计出不大于N的与7有关的数字的个数。如20以内与7有关的数为714173个。





Sample Input





20





Sample Output





3



代码:


[font='Times New Roman']#include<stdio.h>[/font]

[font='Times New Roman']void main()[/font]

[font='Times New Roman']{[/font]

[font='Times New Roman']int n,i,j,a,m,k,t,s=0;[/font]

[font='Times New Roman']scanf("%d",&n);[/font]

[font='Times New Roman']if(n<=30000)[/font]

      [font='Times New Roman']for(t=7;t<=n;t++)[/font]

[font='Times New Roman']{[/font]

[font='Times New Roman']  i=t/10000;[/font]

[font='Times New Roman']  j=(t-10000*i)/1000;[/font]

    [font='Times New Roman']a=(t-10000*i-j*1000)/100;[/font]

    [font='Times New Roman']m=(t-10000*i-j*1000-a*100)/10;[/font]

    [font='Times New Roman']k=t%10;[/font]



[font='Times New Roman']if(i==7||j==7||a==7||m==7||k==7||t%7==0)[/font]

[font='Times New Roman']s++;[/font]

[font='Times New Roman']}[/font]

[font='Times New Roman']printf("%d\n",s);              [/font]

[font='Times New Roman']}[/font]

返回页首 向下
http://tyren.longluntan.org
 
【敲七】
返回页首 
1页/共1

您在这个论坛的权限:不能在这个论坛回复主题
天涯人论坛 :: 我爱编程 :: c语言-
转跳到: