首页 > 其他 > 详细

找出个位数为6且能被3整除的五位数

时间:2014-08-17 01:01:41      阅读:464      评论:0      收藏:0      [点我收藏+]

根据:能被3整除的数其各位的总和也能被3整除的原则,个位6能被3整除,所以就只用考虑高位4位,在这里就可以采用如下方法获得最终结果

 1 /*==================================
 2 Copyright (C) 2014 All rights reserved.
 3 FileName:3.c
 4 author:donald
 5 date:2014/08/16/ 23:35:55
 6 ===================================*/
 7 #include <stdio.h>
 8 #include <stdlib.h>
 9 #include <string.h>
10 
11 int main(int argc, const char *argv[])
12 {
13     int index,cnt ;
14     for(index = 1000;index < 9999;index ++){
15         if(index % 3 == 0){
16             cnt ++;
17             printf("%8d",index*10 + 6) ;
18         }
19     }
20     printf("\nresult is %d \n",cnt);
21     return 0;
22 }

 

找出个位数为6且能被3整除的五位数,布布扣,bubuko.com

找出个位数为6且能被3整除的五位数

原文:http://www.cnblogs.com/ben1314/p/3917141.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!