Home > Back-end >  Turn a C language problem
Turn a C language problem

Time:09-15

Level needs you to complete a statistical [1, N) within the scope of the sum of digits can be divided exactly by 15 the integer number of small procedures,
For example: 78 is the sum of digits: 7 + 8=15, 78 is a sum of digits can be divided exactly by 15 integer, 56 of each number is the sum of: 5 + 6=11, is the sum of 56 is not a number you can be divided exactly by 15 integer, such as 100 is output 4. Would like to ask why can't my code output?

CodePudding user response:

The above are regular code, there is no stick out

CodePudding user response:

CodePudding user response:

 # include & lt; stdio.h> 
Int main ()
{
Int n, I, temp, sum, count=0;

The scanf (" % d ", & amp; N);
For (I=1; i<=n; I++) {
sum=0;
Temp=I;
While (temp & gt; 0) {//break down each array and the sum
The sum +=temp % 10;
Temp/=10;
}
If (sum % 15==0) {
Printf (" % d: % d \ n ", + + count, I);
}
}
Printf (" count=% d \ n ", count);
return 0;
}

CodePudding user response:

The building code should be a dead loop, because of the for loop variable is I, have a look at the building Lord while loop also use I, and I operate I=I/10; So I change then becomes zero.
  • Related