Jump to content

Citire Numar In Java?


Ovidiu29

Recommended Posts

Acum cateva zile am auzit ca Java se aseamana foarte mult cu C++ doar ca Java e orientat mai mult pe programarea pe obiecte.


public class Proiect {
	public static void main(String[] args) {
		int n=18,flag=1,d;
		if(n%2==0) flag=0;
		else
		{
			for(d=3;d*d<=n;d+=2);
			{
				if(n%d==0) flag=0;
				else flag=1;
			}
		}
		if(flag==1) System.out.println("Da.");
		else System.out.println("Nu.");		
	}

}

Faza e ca vreau sa pot citi si un nr. Am cautat pe net si nici una dintre metode nu a mers. Ma poate ajuta cineva?

Respecta si vei fi respectat.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • 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.