#include
Int main ()
{
Int I, num=0, sum=0;
For (I=0;; I++)
{
If ((I + 3) % 5==0 & amp; & (I - 3) % 6==0)
{
Sum=sum + I;
Num=num + 1;
}
If (num==15) break;
}
Printf (" % d \ n ", sum);
Num=0;
For (I=0;; I++)
{
If ((I + 3) % 5==0 & amp; & (I - 3) % 6==0)
{
Num=num + 1;
Printf (" % d 6 ", I);
}
If (num % 5==0)
printf("\n");
If (num==15) break;
}
return 0;
}
Why the code to run when a line of a page?
CodePudding user response:
Bro, because in front of the starting from 0 several number does not meet the if ((I + 3) % 5==0 & amp; & (I - 3) % 6==0) this condition, the num you has always been to 0, 0%5==0, so has been output line, the solution for the if (num % 5==0) printf (" \ n "); In aIf ((I + 3) % 5==0 & amp; & (I - 3) % 6==0)
{
Num=num + 1;
Printf (" % d 6 ", I);
}
This can solve inside, there is this code you can put inside a loop can be solved, don't need to make two for loop,
CodePudding user response:
# include & lt; Iostream>
using namespace std;
Int main () {
Int I=1;
Int num=0;
White (1) {
If (I % 3==0 & amp; I % 5==0 & amp; (1-3) % 6==0) {
Coutnum++;
}
If (num==15) return 0;
If (num % 5==0) {
Cout}
i++;
}
}
CodePudding user response: