Jump to content

Recommended Posts

  • Moderators
Posted

Salut.

 

Am instalat Code::Blocks, dupa care: Console Aplication > am bagat numele > C++ > GNU Compiler. 

 

Am scris programelul in main.cpp asa:

 


#include <iostream>

using namespace std;

int main()
{
    int a,b,i,prim,d,k=0;
    f>>a>>b;
    for(i=a;i<=b;i++)
    {
        prim=0;
	    for(d=2;d<=i/2;d++)
            {
                if(i%d==0)
                prim=1;
            }
            if(prim==0)
            {
            g<<i<<" ";
		    k++;
            }
    }
    if(k==0)
    g<<"Nu este niciun numar prim in intervalul ["<<a<<","<<b<<"].";
    return 0;
}
 

Am dat Save > Build & Run. Nicio eroare gasita, dar nu se inampla nimic :(.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.