标签:style blog color io for ar 2014 div
根据:能被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
标签:style blog color io for ar 2014 div
原文地址:http://www.cnblogs.com/ben1314/p/3917141.html