-
yao314
java实现:for (int i = 0; i < 100; i++) { if (((i+3)%5)==0 && ((i-3)%6)==0) { System.out.println(i); } }0-99这100个正整数,同时满足条件(与3的和是5的倍数,与3的差是6的倍数)。结果为:27 57 87
-
suegeeker
function getQueryNum($n){
$counter=0;
$start=1;
do{
$tmp=$start*10+7;
if((($tmp+3)%5==0)&&($tmp-3)%6==0)){
$counter++;
echo $tmp;
}
$start++;
}while($counter<=$n);
}少写了个$start++;思路: 个位可定是7;
-
suegeeker
function getQueryNum($n){
$counter=0;
$start=1;
do{
$tmp=$start*10+7;
if((($tmp+3)%5==0)&&($tmp-3)%6==0)){
$counter++;
echo $tmp;
}
}while($counter<=$n);
}
-
bellstire
#include <stdio.h>int main(){ int a,n; scanf("%d",&n); for(a=1;a<=n;a++) { if((a+3)%5==0) { if((a-3)%6==0) { printf("%d\n",a); } else { continue; } } else { continue; } } getchar();getchar(); return 0;}开始输入范围n