-
There are problems with your judgment, so I won't talk about the semicolon, I rewrote it, and your logic is not right, if(i%k!=0) cout<
#include
using namespace std;
int main()
int i,k;
int flag;
for(i=100;i<=200;i++)flag=-1;
for(k=2;k<=(int)sqrt(i);k++)if(i%k==0)
flag=0;
break;
if (flag!=0)
cout
-
#include
#include
using namespace std;
int main()
int i,k;
for(i=100;i<=200;i++) You have one more garry for this part; It's an empty loop.
for(k=2;k<=(int)sqrt(i);k++) here you also add one; is an empty loop.
if(i%k!=0) cout
-
for(i=100;i<=200;i++) is wrong here and should be removed.
for(k=2;k<=(int)sqrt(i);k++) is wrong here and should be removed.
The above are 2 empty for loops, and there is definitely no result.
-
The for statement is not followed by a semicolon.
-
Determining whether a number is x or not is prime is whether there is an epwinkbetween 2 - sqrt(x); No, it's prime.
Then make a cycle from 100 - 200 to determine whether each number is prime.
-
Several methods such as training loops and amorphous loops, arrays and pointers are all possible.
-
Two methods: 1. Violence; 2. Finding prime numbers by screening method.
The first type: the brute force method, use each number from 100 to 200 in the cycle to judge it, and output it if it is a prime number.
#include
#include
using namespace std;
bool prime(int num)
int main()
There should be a condition:
main() >>>More
Spring The lovely spring girl, with light steps, came to the world, and the scene of vitality came in all directions, and the whole world seemed to have just woken up from a long sleep. >>>More
I like to quietly gaze at the teacher's bright eyes—such beautiful and innocent eyes, which warm people's hearts. When I stepped into the campus, it was your eyes that gave me kindness; When I was disappointed in the exam room, it was your eyes that gave me encouragement; When I am complacent, it is your eyes that warn me. Flashing with light but without a hint of flashiness, full of truth but without a trace of falsehood, slightly serious but not a trace of sharpness. >>>More
No, you write it yourself, and you copy it.
At 8 p.m. on August 8, 2008, the 29th Beijing Olympic Games opened on time! >>>More