Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- using namespace std;
- int main()
- {
- int M,N,br=0;
- int broj[10000] = {0};
- int i,j,temp,naj=0;
- ofstream out("test3.txt");
- for (int i = 0; i < 1; i++) {
- do{
- cout<<"Unesi M: ";cin>>M;
- cout<<"Unesi N: ";cin>>N;
- }while(M<10000 || M>N || N>99999);
- out<<"Prosti brojevi izmedu "<<M<<" i "<<N<<" su: ";
- while (M < N) // trazimo proste brojeve izmedu M i N
- {
- int flag = 0;
- for(i = 2; i <= M/2; ++i)
- {
- if(M % i == 0)
- {
- flag = 1;
- break;
- }
- }
- if (flag == 0){
- out << M <<endl; // ispis prostog broja
- broj[br] = M;
- br++;
- }
- ++M;
- }
- }
- out.close();
- for (i = 0; i < 10; i++)
- {
- for (j = i + 1; j < i+2; j++)
- {
- if(i==0 )naj = broj[j]-broj[i];
- if((broj[j]-broj[i]) > naj) naj = broj[j] - broj[i];
- }
- }
- cout<<"Najveca razlika je: "<<naj<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement