You need to finish the inner loop before output the corresponding data.
Problem: Output primes within 100 to 999 in rows of 8.
Error: The non-prime number 591 occurs. Don't understand what went wrong
code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i,j,count;
count=0;
for(i=100;i<999;i++)
{
for(j=2;j<=i;j++)
{
if(i%j==0)
{
break;
}
else
{
count++;
printf(" %d ",i);
if(count%8==0)
{
printf("\n");
}
break;
}
}
}
return 0;
}
Question Screenshot:
0 Answer
这家伙很懒,什么都没留下...