التميز خلال 24 ساعة | |||
العضو الأكثر نشاطاً هذا اليوم | الموضوع النشط هذا اليوم | المشرف المميزلهذا اليوم | |
قريبا | بقلم : | الرهيب |
« آخـــر الـــمـــشـــاركــــات » |
الحاسب الآلي يختص بامور الحاسب الآلي والبرامج وكل ما هو جديد في هذا المجال |
الإهداءات |
| LinkBack | أدوات الموضوع |
03-01-2009, 02:55 PM | #1 |
| java program السلام عليكم ورحمة الله وبركاته هذه بعض الا كواد للجافا تستخدم في برنامج الجافا التعليمي: import java.util.*; class BinaryTree { BinaryTree left; BinaryTree right; int value; public BinaryTree (int v) { value=v; } public void insert(int v) { if(v<value) { if(left==null) left=new BinaryTree(v); else left.insert(v); } if(v>value) { if(right==null) right=new BinaryTree(v); else right.insert(v); } } public void display() { System.out.println(value); System.out.println(left.value); System.out.println(right.value); } public static void main (String args[]) { BinaryTree b=new BinaryTree(50); b.insert(20); b.insert(30); b.insert(60); b.display(); } } ---------------------------------------------------------------------------------------------------------------------------- /*Factorial of a Number Recursive Function */ import javax.swing.*; class Factorial { int num; public void EnterValue() { String str; str=JOptionPane.showInputDialog(null,"Enter a Number to find Factorial: "); num=Integer.parseInt(str); } public int factorial(int n) { if (n == 1) return 1; return n * factorial(n-1); //Recursive Function } public static void main(String args[]) { int result; Factorial f=new Factorial(); f.EnterValue(); result=f.factorial(f.num); System.out.println("The Factorial of a Number is: "+result); } } ---------------------------------------------------------------------------------------------------------------------------- /*Power of a Number Recursive Function */ import javax.swing.*; class Power { static double n ,x; public void EnterValue() { String str1,str2; str1=JOptionPane.showInputDialog(null,"Enter a Base Value to find Power: "); x=Double.parseDouble(str1); str2=JOptionPane.showInputDialog(null,"Enter a Power Value to find Power: "); n=Double.parseDouble(str2); } public static double power(double x,double n) { if(n<0) { JOptionPane.showMessageDialog(null,"Enter only positive number: "); System.exit(0); } if (n == 0) return 1.0; return (x * power(x,(n-1))); //Recursive Function } public static void main(String args[]) { double result; Power p=new Power(); p.EnterValue(); result=Power.power(x,n); JOptionPane.showMessageDialog(null,"The Power of a number is: "+result); } } ---------------------------------------------------------------------------------------------------------------------------- import javax.swing.*; class Search { int n,x; int a[ ]=new int[20]; void getData() { String s=JOptionPane.showInputDialog(null,"Number of Elements: "); n=Integer.parseInt(s); JOptionPane.showMessageDialog(null,"Enter the Elements: "); for(int i=0;i<n;i++) { s=JOptionPane.showInputDialog(null,"Element= "); a[i]=Integer.parseInt(s); } System.out.println("Enter the Element to Search: "); s=JOptionPane.showInputDialog(null,"Element to search: "); x=Integer.parseInt(s); } int binSearch(int low,int high) { int mid; if(low>high) return -1; mid=(low+high)/2; if(x==a[mid]) return mid; else if(x<a[mid]) return binSearch(low,mid-1); else return binSearch(mid+1,high); //return x==mid?mid:x<a[mid]?binSearch(low,mid-1):binSearch(mid+1,high); } } class Binary_Search { public static void main(String args[]) { int m; Search s=new Search(); s.getData(); int found=s.binSearch(0,5); if(found==-1) JOptionPane.showMessageDialog(null,"Not Found: "); else JOptionPane.showMessageDialog(null,"Found at Location: "+found); } } المصدر: منتديات بني بحير بلقرن java program |
03-01-2009, 05:41 PM | #2 |
مستشار موقع بني بحير بلقرن | رد: java program اخي المتحري رائع وننتظر الجديد شـكــ وبارك الله فيك ـــرا لك ... لك مني أجمل تحية . |
03-01-2009, 09:06 PM | #4 |
| رد: java program شـكــ وبارك الله فيك ـــرا لك ... لك مني أجمل تحية . وهذا اقل مانقدمه للمنتدى |
الذين يشاهدون محتوى الموضوع الآن : 1 ( الأعضاء 0 والزوار 1) | |
| |
المواضيع المتشابهه | ||||
الموضوع | كاتب الموضوع | المنتدى | مشاركات | آخر مشاركة |
Download+watch online البرنامج الرائع 2012 4.1 Mobile Number Locator for Java | عزراءالصيف | ملتقى الصحافه والاعلام | 0 | 07-22-2012 11:48 PM |
برنامج تحديد مكان المتصل - Mobile Number Locator 4.1 for Java | أسماء محفوظ | الحاسب الآلي | 4 | 12-23-2011 10:34 PM |
Rss Rss 2.0 Html Xml Sitemap دليل المنتديات