• الإعلانات

    • فيصل الحربي

      تسجيل عضوية جديدة في المنتدى   01/31/2016

      السلام عليكم ورحمة الله وبركاته  عزيزي العضو الجديد :  حاليا رسالة الإيميل لتأكيد صحة إيميلكم تذهب للبريد العشوائي ( جاري حل المشكلة )  فإذا لم تجد رسالة التحقق من إيميلكم في صندوق الوارد لديكم إتجه للبريد العشوائي ( JUNK)  وقم بتفعيل إشتراككم من هناك   

طالبة مجتهدة 2012

اعضاء جدد
  • عدد المشاركات

    17
  • تاريخ الانضمام

  • تاريخ اخر زياره

السمعه بالموقع

-1 مقبول

عن طالبة مجتهدة 2012

  • الرتبة
    عضو جديد

معلومات الملف الشخصي

  • الجنس أنثى
  1. حل مشكلة بالـ Wamp

    تم حل المشكلة  ارجو حذف الموضوع
  2. تم حل المشكلة بالكود الاول و الان بنشتغل على الكود الثاني فيها اخطاء #include <stdio.h>#include <stdlib.h>#include <string.h> /*to use strcpy*/#include <stddef.h> /*to use NULL*/ #define N 4#define SEED 1234567 struct words{ char word[N+1]; int used; /*If used is 1, word has been used and if used is 0, it has not.*/};typedef struct words WORDS; struct treenode{ char data[N+1]; struct treenode *left; struct treenode *right;};typedef struct treenode NODE; WORDS words[1000]={0};NODE data[N+1]={0};FILE *W4;NODE *root; void getWords(void);void printWords(void);void randomWords(void);NODE *insert(NODE *root, char *word);void traverse(NODE *root); int main(void){ getWords(); /*printWords();*/ randomWords(); root=NULL; traverse(root); system("PAUSE"); return 0;} void getWords(void){ int c=0, i=0, j=0; /*i increments words, j increments string*/ char string[N+1]; /*read in 1000 words from W4*/ W4=fopen("W4", "r"); while((c=getc(W4))!=EOF){ if(i!=1000){ if(c!='\n'&&c!=' ') { if(j==N){ i++; string[j]='\0'; /*terminate string*/ /*printf("%s ", string);*/ strcpy(words[i].word, string);/*store string into an array*/ j=0; /*reset string incrementer to 0*/ string[j]=c; /*read in next character*/ j++; } else{ string[j]=c; /*read in a character*/ j++; } } else j=0; } } fclose(W4); printf("\n%d words have been put in the array words[1000].\n", i);} void printWords(void){ int i; for(i=0;i<1000;i++) printf("%s%d ", words[i].word, words[i].used);} void randomWords(void){ int i, randnum; /* initialize random generator */ srand(SEED); for(i=0;i<100;i++){ randnum=rand()%1000; if(words[randnum].used!=1)/* generate a random number */ /*printf("%d:%d ", i+1, randnum);*/ /*printf("%s ", words[randnum].word);*/ insert(root, words[randnum].word); words[randnum].used=1; }} NODE *insert(NODE *node, char *word){ if(node==NULL){ node=(NODE *) malloc(sizeof(NODE)); strcpy(node->data, word); node->left=NULL; node->right=NULL; } else{ if(strcmp(word, node->data)<0) insert(node->left, word); else if(strcmp(word, node->data)>0) insert(node->right, word); } return node;} void traverse(NODE *root){ if(root!=NULL){ traverse(root->left); /*recur left*/ printf("%s ", root->data); traverse(root->right); /*recur right*/ }}
  3. كيف يمكننا كتابة جملة الـinsert  المشكلة بالكود الان انها لا ترسل الكلمات اللي تقراها للدالة اللي ببداية الكود التي تقوم بترتيب الكلمات ابجدياً ممكن توضيح اكثر لان حاولت اطبق الرد ما عرفت
  4. السلام عليكم عندي كودين تعمل نفس الغرض  ترتب الكلمات المدخلة ترتيب ابجدي زي الدكشنري مطلوب مننا اننا ندور الاكواد جاهزة و نضيف له الرن تايم فانكشن و كمان اهم شي انه يكون المدخلات بملف لحال و نعمل له استدعاء من الكود الاساسي لقينا الاكواد و اضفنا له الرن تايم فانكشن و الحمد لله اشتغل بس مشكلتنا الان حاولنا كثير اننا نخلي المدخلات بملف لحال  هذا الكود الاول شغال    // C program to demonstrate Ternary Search Tree (TST) insert, travese // and search operations#include <stdio.h>#include <stdlib.h>#define MAX 50#include <time.h> FILE *infile; FILE *outfile; // A node of ternary search treeclock_t start = clock();clock_t end;struct Node{ char data; // True if this character is last character of one of the words unsigned isEndOfString: 1; struct Node *left, *eq, *right;}; // A utility function to create a new ternary search tree nodestruct Node* newNode(char data){ struct Node* temp = (struct Node*) malloc(sizeof( struct Node )); temp->data = data; temp->isEndOfString = 0; temp->left = temp->eq = temp->right = NULL; return temp;} // Function to insert a new word in a Ternary Search Treevoid insert(struct Node** root, char *word){ // Base Case: Tree is empty if (!(*root)) *root = newNode(*word); // If current character of word is smaller than root's character, // then insert this word in left subtree of root if ((*word) < (*root)->data) insert(&( (*root)->left ), word); // If current character of word is greate than root's character, // then insert this word in right subtree of root else if ((*word) > (*root)->data) insert(&( (*root)->right ), word); // If current character of word is same as root's character, else { if (*(word+1)) insert(&( (*root)->eq ), word+1); // the last character of the word else (*root)->isEndOfString = 1; }} // A recursive function to traverse Ternary Search Treevoid traverseTSTUtil(struct Node* root, char* buffer, int depth){ if (root) { // First traverse the left subtree traverseTSTUtil(root->left, buffer, depth); // Store the character of this node buffer[depth] = root->data; if (root->isEndOfString) { buffer[depth+1] = '\0'; printf( "%s\n", buffer); } // Traverse the subtree using equal pointer (middle subtree) traverseTSTUtil(root->eq, buffer, depth + 1); // Finally Traverse the right subtree traverseTSTUtil(root->right, buffer, depth); }} // The main function to traverse a Ternary Search Tree.// It mainly uses traverseTSTUtil()void traverseTST(struct Node* root){ char buffer[MAX]; traverseTSTUtil(root, buffer, 0);} // Function to search a given word in TSTint searchTST(struct Node *root, char *word){ if (!root) return 0; if (*word < (root)->data) return searchTST(root->left, word); else if (*word > (root)->data) return searchTST(root->right, word); else { if (*(word+1) == '\0') return root->isEndOfString; return searchTST(root->eq, word+1); }} // Driver program to test above functionsint main(){ struct Node *root = NULL; insert(&root, "cat");insert(&root, "cats");insert(&root, "up");insert(&root, "bug");insert(&root, "able");insert(&root, "acid");insert(&root, "angry");insert(&root, "automatic");insert(&root, "awake");insert(&root, "bad");insert(&root, "beautiful");insert(&root, "bent");insert(&root, "bitter");insert(&root, "black");insert(&root, "blue");insert(&root, "boiling");insert(&root, "bright");insert(&root, "broken");insert(&root, "brown");insert(&root, "certain");insert(&root, "cheap");insert(&root, "chemical");insert(&root, "chief");insert(&root, "clean");insert(&root, "clear");insert(&root, "cold");insert(&root, "common");insert(&root, "complete");insert(&root, "complex");insert(&root, "conscious");insert(&root, "cruel");insert(&root, "cut");insert(&root, "dark");insert(&root, "dead");insert(&root, "dear");insert(&root, "deep");insert(&root, "delicate");insert(&root, "dependent");insert(&root, "different");insert(&root, "dirty");insert(&root, "dry");insert(&root, "early");insert(&root, "elastic");insert(&root, "electric");insert(&root, "equal");insert(&root, "false");insert(&root, "fat");insert(&root, "feeble");insert(&root, "female");insert(&root, "fertile");insert(&root, "first");insert(&root, "fixed");insert(&root, "flat");insert(&root, "foolish");insert(&root, "free");insert(&root, "frequent");insert(&root, "full");insert(&root, "future");insert(&root, "general");insert(&root, "good");insert(&root, "gray");insert(&root, "great");insert(&root, "green");insert(&root, "hanging");insert(&root, "happy");insert(&root, "hard");insert(&root, "healthy");insert(&root, "high");insert(&root, "hollow");insert(&root, "ill");insert(&root, "important");insert(&root, "kind");insert(&root, "last");insert(&root, "late");insert(&root, "left");insert(&root, "like");insert(&root, "living");insert(&root, "long");insert(&root, "loose");insert(&root, "loud");insert(&root, "low");insert(&root, "male");insert(&root, "married");insert(&root, "material");insert(&root, "medical");insert(&root, "military");insert(&root, "mixed");insert(&root, "narrow");insert(&root, "natural");insert(&root, "necessary");insert(&root, "new");insert(&root, "normal");insert(&root, "old");insert(&root, "open");insert(&root, "opposite");insert(&root, "parallel");insert(&root, "past");insert(&root, "physical");insert(&root, "political");insert(&root, "poor");insert(&root, "possible");insert(&root, "present");insert(&root, "private");insert(&root, "probable"); printf("Following is traversal of ternary search tree\n"); traverseTST(root); /* printf("\nFollowing are search results for cats, bu and cat respectively\n"); searchTST(root, "cats")? printf("Found\n"): printf("Not Found\n"); searchTST(root, "bu")? printf("Found\n"): printf("Not Found\n"); searchTST(root, "cat")? printf("Found\n"): printf("Not Found\n"); */ end = clock();printf("\n%f\n", (double)(end - start));return 0;}وهذا الكود بعد محاولة فصل المدخلات بملف صيغتها و اسمها "Eb.txt"و استدعاها   // C program to demonstrate Ternary Search Tree (TST) insert, travese // and search operations#include <stdio.h>#include <stdlib.h>#define MAX 50#include <time.h> FILE *infile; FILE *outfile; // A node of ternary search treeclock_t start = clock();clock_t end;struct Node{ char data; // True if this character is last character of one of the words unsigned isEndOfString: 1; struct Node *left, *eq, *right;}; // A utility function to create a new ternary search tree nodestruct Node* newNode(char data){ struct Node* temp = (struct Node*) malloc(sizeof( struct Node )); temp->data = data; temp->isEndOfString = 0; temp->left = temp->eq = temp->right = NULL; return temp;} // Function to insert a new word in a Ternary Search Treevoid insert(struct Node** root, char *word){ // Base Case: Tree is empty if (!(*root)) *root = newNode(*word); // If current character of word is smaller than root's character, // then insert this word in left subtree of root if ((*word) < (*root)->data) insert(&( (*root)->left ), word); // If current character of word is greate than root's character, // then insert this word in right subtree of root else if ((*word) > (*root)->data) insert(&( (*root)->right ), word); // If current character of word is same as root's character, else { if (*(word+1)) insert(&( (*root)->eq ), word+1); // the last character of the word else (*root)->isEndOfString = 1; }} // A recursive function to traverse Ternary Search Treevoid traverseTSTUtil(struct Node* root, char* buffer, int depth){ if (root) { // First traverse the left subtree traverseTSTUtil(root->left, buffer, depth); // Store the character of this node buffer[depth] = root->data; if (root->isEndOfString) { buffer[depth+1] = '\0'; printf( "%s\n", buffer); } // Traverse the subtree using equal pointer (middle subtree) traverseTSTUtil(root->eq, buffer, depth + 1); // Finally Traverse the right subtree traverseTSTUtil(root->right, buffer, depth); }} // The main function to traverse a Ternary Search Tree.// It mainly uses traverseTSTUtil()void traverseTST(struct Node* root){ char buffer[MAX]; traverseTSTUtil(root, buffer, 0);} // Function to search a given word in TSTint searchTST(struct Node *root, char *word){ if (!root) return 0; if (*word < (root)->data) return searchTST(root->left, word); else if (*word > (root)->data) return searchTST(root->right, word); else { if (*(word+1) == '\0') return root->isEndOfString; return searchTST(root->eq, word+1); }} // Driver program to test above functionsint main(){ { FILE *fp; char *fileName = "Eb.txt"; char letter; struct Node *root = NULL; fp = fopen(fileName, "r"); /* insert(&root, "cat");insert(&root, "cats");insert(&root, "up");insert(&root, "bug");insert(&root, "able");insert(&root, "acid");insert(&root, "angry");insert(&root, "automatic");insert(&root, "awake");insert(&root, "bad");insert(&root, "beautiful");insert(&root, "bent");insert(&root, "bitter");insert(&root, "black");insert(&root, "blue");insert(&root, "boiling");insert(&root, "bright");insert(&root, "broken");insert(&root, "brown");insert(&root, "certain");insert(&root, "cheap");insert(&root, "chemical");insert(&root, "chief");insert(&root, "clean");insert(&root, "clear");insert(&root, "cold");insert(&root, "common");insert(&root, "complete");insert(&root, "complex");insert(&root, "conscious");insert(&root, "cruel");insert(&root, "cut");insert(&root, "dark");insert(&root, "dead");insert(&root, "dear");insert(&root, "deep");insert(&root, "delicate");insert(&root, "dependent");insert(&root, "different");insert(&root, "dirty");insert(&root, "dry");insert(&root, "early");insert(&root, "elastic");insert(&root, "electric");insert(&root, "equal");insert(&root, "false");insert(&root, "fat");insert(&root, "feeble");insert(&root, "female");insert(&root, "fertile");insert(&root, "first");insert(&root, "fixed");insert(&root, "flat");insert(&root, "foolish");insert(&root, "free");insert(&root, "frequent");insert(&root, "full");insert(&root, "future");insert(&root, "general");insert(&root, "good");insert(&root, "gray");insert(&root, "great");insert(&root, "green");insert(&root, "hanging");insert(&root, "happy");insert(&root, "hard");insert(&root, "healthy");insert(&root, "high");insert(&root, "hollow");insert(&root, "ill");insert(&root, "important");insert(&root, "kind");insert(&root, "last");insert(&root, "late");insert(&root, "left");insert(&root, "like");insert(&root, "living");insert(&root, "long");insert(&root, "loose");insert(&root, "loud");insert(&root, "low");insert(&root, "male");insert(&root, "married");insert(&root, "material");insert(&root, "medical");insert(&root, "military");insert(&root, "mixed");insert(&root, "narrow");insert(&root, "natural");insert(&root, "necessary");insert(&root, "new");insert(&root, "normal");insert(&root, "old");insert(&root, "open");insert(&root, "opposite");insert(&root, "parallel");insert(&root, "past");insert(&root, "physical");insert(&root, "political");insert(&root, "poor");insert(&root, "possible");insert(&root, "present");insert(&root, "private");insert(&root, "probable"); */ printf("Following is traversal of ternary search tree\n"); do { fscanf(fp, "%c", &letter); printf("%c", letter); } while(!feof(fp)); printf("\n"); fclose(fp); traverseTST(root); } /* printf("\nFollowing are search results for cats, bu and cat respectively\n"); searchTST(root, "cats")? printf("Found\n"): printf("Not Found\n"); searchTST(root, "bu")? printf("Found\n"): printf("Not Found\n"); searchTST(root, "cat")? printf("Found\n"): printf("Not Found\n"); */ end = clock(); printf("\n%f\n", (double)(end - start));}يظهر لنا الاوون بوت و يطلع لنا الرن تايم بس الاون بوت ما يترسل للديكشنري فنكشن يعني ما يكون مرتب ترتيب ابجدي و كمان يكرر اخر حرف باخر كلمة حاولنا كثييييييييييير فيه نحنا ما درسنا شي زي كدا و بحثنا بالنت عن الطريقة و جربناها زي الكود اللي فوق و ما زبط    
  5. Phone Directory program

    حاولت كثيييييييير بكل الانواع مااااا زبط :( خلاص يعني ما في حل
  6. Phone Directory program

    بكرة ان شاء الله تسليم المشروع عندي مشكلتين اول مشكلة انه لما يختار المستخدم رقم 4 لعملية ادخال بيانات جديدة لللستة يروح يساله عن رقم الروم الجديد اللي يبغى يضيفه و اسم الاستاذة و رقم الاي دي و الهاتف و يطلع له اللستة بعد اضافة المعلومات الجديدة بس المشكلة بترتيب المسافة مو زابط رايح ع اليسار شوي حاولت ازبطه ما زبط :( و ثاني مشكلة لما يطلب من المستخدم رقم الروم و بعدها اسم الاستاذة الجديدة اللي يبغى يضيفها للستة لو دخل المستخدم مثلا ( الاء احمد ) ع طول يطلع له القائمة بعد اضافة البيانات و يحسب الااء كاسم الاستاذة و كلمة احمد ع رقم هاتف :( يعني ما ينفع الا ادخل اسم واحد من غير اسم الوالد و هذي الاكواد Class Link //=============================================================================================== public class Link { public String Teacher_Name; public String teacher_ID; public String Phone_number; public int Room_Number; public Link next; // next link in list public Link previous; // previous link in list //=============================================================================================== public Link(int a, String b, String teacher, String Phone) // constructor { Room_Number = a; teacher_ID = b; Teacher_Name = teacher; Phone_number = Phone; } //=============================================================================================== public void displayLink1() // display this link { System.out.println("\t" + Teacher_Name + "\t\t{" + Room_Number + "}"); System.out.println(""); } //=============================================================================================== public void displayLink2() { System.out.print("\t" + Room_Number); System.out.print("\t" + teacher_ID); System.out.print("\t" +Teacher_Name); System.out.println("\t\t{" + Phone_number + "}"); } } //=============================================================================================== Class DoublyLinkList //=============================================================================================== class DoublyLinkList { private Link first; // ref to first link on list //=============================================================================================== public DoublyLinkList() // constructor { first = null; // no links on list yet } //=============================================================================================== public boolean isEmpty() // true if list is empty { return (first == null); } //=============================================================================================== // insert at start of list public String insertFirst(int a, String ID, String teacher, String Phone) { Link newLink = new Link(a, ID, teacher, Phone); newLink.next = first; first = newLink; return first.Room_Number + " " + first.teacher_ID + " " + first.Teacher_Name + "{" + first.Phone_number + "}"; } //=============================================================================================== public void displayList() { System.out.println("\t\t\n\n *~...~* Welcome *~...~*\n\n "); System.out.print("\n\n\t\t The Menue \n\n"); System.out.println("\n\t :: NAME OF TEACHERS ::\t\t:: NUMBER OF ROOM ::"); System.out.println(""); Link current = first; // start at beginning of list while (current != null) // until end of list, { current.displayLink1(); // print data current = current.next; // move to next link } System.out.println(""); } //=============================================================================================== public Link find(int key) // find link with given key { // (assumes non-empty list) Link current = first; // start at 'first' while (current.Room_Number != key) // while no match, { if (current.next == null) // if end of list, return null; // didn't find it else // not end of list, current = current.next; // go to next link } return current; // found it } //=============================================================================================== public Link delete(int key) // delete link with given key { // (assumes non-empty list) Link current = first; // search for link Link previous = first; while (current.Room_Number != key) { if (current.next == null) return null; // didn't find it else { previous = current; // go to next link current = current.next; } } // found it if (current == first) // if first link, first = first.next; // change first else // otherwise, previous.next = current.next; // bypass it return current; } //=============================================================================================== public void insertLast(int new1, String new2, String new3, String new4) { Link newLink = new Link( new1, new2, new3, new4); // make new link first.previous = newLink; // newLink <-- old first newLink.next = first; // newLink --> old first first = newLink; // first --> newLink } //=============================================================================================== public void display2() { System.out.print("\t\t *~...~* The Menue *~...~* \n\n"); System.out.println("\n\tR.N. ID TEACHER NAME \t PHONE NUMBER\n "); Link current = first; // start at beginning of list while (current != null) // until end of list, { current.displayLink2(); // print data current = current.next; // move to next link } System.out.println(""); } } //=============================================================================================== Class DoublyLinkedApp //=============================================================================================== import java.util.Scanner; import javax.swing.JOptionPane; import javax.swing.JFrame; class DoublyLinkedApp { public static void main(String[] args) { DoublyLinkList theList = new DoublyLinkList(); Scanner input = new Scanner(System.in); int c=0; int a = 0; int b = 0; Link f; theList.insertFirst(16, "08120014", "Ms. Fahmeeda Aziz","043258088"); theList.insertFirst(15, "08120014", "Dr. Farhana Shaheen ","043258088"); theList.insertFirst(14, "08120014", "Dr. Fatima Al-Zwaihri ", "043258088"); theList.insertFirst(13, "08120014", "Dr. Tahani Sindi ", "043258088"); theList.insertFirst(12, "08120014", "Dr. Nagla Osman ", "043935024"); theList.insertFirst(11, "08120014", "Ms. Atiya Azmi ", "043258088"); theList.insertFirst(10, "08120014", "Ms. Aisha Al-Johani ", "043258088"); theList.insertFirst(9, "08120014", "Ms. Siti Haryani Mohd ", "043935024"); theList.insertFirst(8,"08120014", "Ms.Humera Ghani ", "043258088"); theList.insertFirst(7, "08120014", "Ms. Salma Sadiqha ", "043258088"); theList.insertFirst(6, "08120014", "Ms. Azra Sultana ", "043935024"); theList.insertFirst(5, "08120014", "Ms. Ruchi Tuli ", "043258088"); theList.insertFirst(4, "08120014", "Ms. Fozia Noor ", "043258088"); theList.insertFirst(3, "08120014", "Ms. Kajal nusratullah ", "043258088"); theList.insertFirst(2, "08120014", "Ms.Anusuyah Subbarao ", "043935024"); theList.insertFirst(1, "08120014", "Ms. Aizal Yusrina ", "043258088"); JOptionPane.showMessageDialog (null, " *~...~* WELCOME *~...~*\n\n PHONE DIRECTORY SYSTEM\n\n For Login Please Click Ok\n\n", " {ELECTRONIC SYSTEM OF PHONE DIRECTORY]", JOptionPane.INFORMATION_MESSAGE); JFrame frame = new JFrame(); int SENTINEL = 123; //password number String str; //password number which the user will Enter it int password = 0; int counter = 5; while (counter != 0 && password != SENTINEL) { str = JOptionPane.showInputDialog("Enter Password"); password = Integer.parseInt(str); if(password == SENTINEL) { JOptionPane.showMessageDialog(null, "CORRECT"); System.out.println("\n\t*~...~* The Messages of PHONE DIRECTORY SYSTEM *~...~*\n\n-------------------------------------------------------------------------- \n"); } else if(password!=SENTINEL) { JOptionPane.showMessageDialog(null, "Wrong try again"); } counter = counter-1; if (counter == 0) { JOptionPane.showMessageDialog(null, "Acces Denied!!! \nPlease contact Helpdesk"); System.exit(0); } } while(c!=6) { String Option1 = JOptionPane.showInputDialog(null,"\nPlease Enter The Number of Choice !? \n1) View list ROOM\n2) SEARCH THE DATA OF TEACHER\n3) Remove DATA OF TEACHER list\n4) Insert DATA OF TEACHER list\n5) Exit\n", "Phone Directory Options", JOptionPane.INFORMATION_MESSAGE); c = Integer.parseInt(Option1); // System.out.println("\nPlease Enter The Number of Choice !? \n1) View list ROOM\n2) SEARCH THE DATA OFTEACHER\n3) Remove DATA OF TEACHER list\n4) Insert DATA OF TEACHER list\n5) Exit\n"); // c=input.nextInt(); switch (c) // 5 cases { //=============================================================================================== case 1: { theList.displayList(); System.out.println("---------------------------------------------------------------------------\n"); } break; //=============================================================================================== case 2: System.out.println("\nEnter how MANY TEACHERS U WANT TO FIND"); a=input.nextInt(); for(int j=1;j<=a;j++) { System.out.println("\nEnter Number of Teacher Room ÏÏ "+j+" ÏÏ "); b=input.nextInt(); f = theList.find( b); // find item if(f!=null) { System.out.println("\nTEACHER NAME IS: "+f.Teacher_Name+"\nTEACHER ID: "+f.teacher_ID+"\nPHONE NUMBER IS: "+f.Phone_number); System.out.println("\n---------------------------------------------------------------------------\n"); } else { System.out.println("we did FOUND "+f.Teacher_Name); } } break; //=============================================================================================== case 3: { System.out.println("\nEnter THE ROOM NUMBER OF TEACHER "); int key=input.nextInt(); Link i = theList.delete(key); // delete item if( i != null ) { System.out.println("Deleted NUMBER OF ROOM : "+ i.Room_Number+"\n"); System.out.println("Delet the ID : "+i.teacher_ID +"\n"); System.out.println("Delet the Name Of TEACHER : "+ i.Teacher_Name+"\n" ); System.out.println("Delet the PHONE NUMBER : "+i.Phone_number+"\n"); System.out.println("SUCCESSFUL DELET"); theList.displayList(); System.out.print("---------------------------------------------------------------------------\n"); } else { System.out.println("Can't delete "); System.out.println("the data still in list "+i); // theList.displayList(); } //System.out.print("---------------------------------------------------------------------------\n"); } break; //=============================================================================================== case 4: { System.out.println("NEW NUMBER OF ROOM : "); int new1=input.nextInt(); if(new1==a) { System.out.println("That Room Number Is currently in the list\n"); } else System.out.println("THE ID FOR NEW TEACHER : "); String new2=input.next(); System.out.println("NEW TEACHER NAME : "); String new3=input.next(); System.out.println("PHONE NUMBER OF NEW TEACHER: "); String new4=input.next(); theList.insertLast(new1,new2, new3, new4); theList.display2(); //theList.displayList(); } break; //=============================================================================================== case 5: { System.exit(0); } break; //=============================================================================================== } if(c>6) { System.out.println("YOUAR INPUT NUMBER NOT IN THE LIST\nPLEASE, TRY AGAIN"); } } } } //===============================================================================================
  7. Phone Directory program

    .......
  8. Phone Directory program

    السلام عليكم عندي هذا السؤال و هذا الاوت بوت فكرة البرنامج انه الطالب يبحث عن معلومات استاذة ( اسم المس و رقم التلفون و اي دي الاستاذة) البحث عن طريق رقم روم الاستاذة كتبت الكود باستخدام الدبلي لنك لست لما وريته الاستاذة قالت ضروري انك تضيفي انسيرت مثود ع اساس انه المستخدم يقدر يضيف معلومات استاذات جدد غير الموجودات باللستة اللي بالبرنامج لو ما اضفته ما راح تقبل مني البرنامج :( التسليم بعد كم يووووم اضفت انسيرت مثود بس عندي بعض الايرر و هذي الاربعة كلاسات للبرنامج main class //-------------------------------------------------------------------------------------Backages import java.util.*; import java.util.Scanner; import java.awt.*; import java.awt.event.*; import javax.swing.*; //--------------------------------------------------------------------------------------Class Main public class Main extends JFrame { final Users theUser = new Users(); //------------------------------------------------------------------------------------1--Method main public static void main(String[] args) { new Main().setVisible(true);//call method Main }//end public static void main //-----------------------------------------------------------------------------------2--Mathod Main public Main() { theUser.Users(); //------------------ setTitle("Phone Directory"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //---------------------------------------------------------------------------Date-Photo-size-color Date da = new Date(); Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); contentPane.setBackground(Color.green); setSize(300,300); //------------------- JLabel time = new JLabel(" Today is : " +da); getContentPane().add(time); //---------------- setResizable(false); setLocationRelativeTo(null); String imgStr1 = "c://EQLS.png"; ImageIcon image = new ImageIcon(imgStr1); JLabel label1 = new JLabel(" ", image, JLabel.CENTER); getContentPane().add(label1); validate(); setVisible(true); //-----------------------------------------------------------------------------------------Button1 JButton button1 = new JButton("*~...~* Welcome *~...~*"); button1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog((Component) e.getSource(), "\n\nThe main idea behind my system is\n\n\n to make the search for teacher information easier using a computer system.\n\n"); } });//end button1 //-----------------------------------------------------------------------------------------Button2 JButton button2 = new JButton("Main User Access: Phone Directory"); button2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String Option1 = JOptionPane.showInputDialog(null,"Please Enter The Number of Choice !? \n1) View list ROOM\n2) SEARCH THE DATA OFTEACHER\n3) Remove DATA OF TEACHER list\n4) Delete\n5) Return\n6) Exit\n", "Phone Directory Options", JOptionPane.INFORMATION_MESSAGE); int ConvOption1 = Integer.parseInt(Option1); theUser.mainUser(ConvOption1,Option1);//go to main User method }//end method public void actionListener String Option1 = JOptionPane.showInputDialog( });//end button2 //-----------------------------------------------------------------------------------------Button3 JButton button3= new JButton("Exit"); button3.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { int result = JOptionPane.showConfirmDialog((Component) e.getSource(),"Close Phone Directory SYSTEM"); if (result == JOptionPane.YES_OPTION) {System.exit(0);} } });//end button3 //------------------------------------------------------------------------------------------ // setLayout(new FlowLayout(FlowLayout.CENTER)); setLayout(new GridLayout(8,4)); getContentPane().add(button1); getContentPane().add(button2); getContentPane().add(button3); }//end public method Main //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// }//end class Main users class import javax.swing.JFrame; import java.util.Scanner; import javax.swing.JOptionPane; class Users { linkList theList = new linkList(); Scanner input = new Scanner(System.in); int a = 0; int b = 0; int key,r; Link v,d, f; public void Users() { JOptionPane.showMessageDialog (null, " *~...~* WELCOME *~...~*\n\n PHONE DIRECTORY SYSTEM\n\n For Login Please Click Ok\n\n", " {ELECTRONIC SYSTEM OF PHONE DIRECTORY]", JOptionPane.INFORMATION_MESSAGE); JFrame frame = new JFrame(); int SENTINEL = 123; //password number String str; //password number which the user will Enter it int password = 0; int counter = 5; while (counter != 0 && password != SENTINEL) { str = JOptionPane.showInputDialog("Enter Password"); password = Integer.parseInt(str); if(password == SENTINEL) { JOptionPane.showMessageDialog(null, "CORRECT"); System.out.println("\n\t*~...~* The Messages of PHONE DIRECTORY SYSTEM *~...~*\n\n-------------------------------------------------------------------------- \n"); } else if(password!=SENTINEL) { JOptionPane.showMessageDialog(null, "Wrong try again"); } counter = counter-1; if (counter == 0) { JOptionPane.showMessageDialog(null, "Acces Denied!!! \nPlease contact Helpdesk"); System.exit(0); } } String backupDir="" ; theList.insertFirst(16, "08120014", "Ms. Fahmeeda Aziz","043258088"); theList.insertFirst(15, "08120014", "Dr. Farhana Shaheen ","043258088"); theList.insertFirst(14, "08120014", "Dr. Fatima Al-Zwaihri ", "043258088"); theList.insertFirst(13, "08120014", "Dr. Tahani Sindi ", "043258088"); theList.insertFirst(12, "08120014", "Dr. Nagla Osman ", "043935024"); theList.insertFirst(11, "08120014", "Ms. Atiya Azmi ", "043258088"); theList.insertFirst(10, "08120014", "Ms. Aisha Al-Johani ", "043258088"); theList.insertFirst(9, "08120014", "Ms. Siti Haryani Mohd ", "043935024"); theList.insertFirst(8,"08120014", "Ms.Humera Ghani ", "043258088"); theList.insertFirst(7, "08120014", "Ms. Salma Sadiqha ", "043258088"); theList.insertFirst(6, "08120014", "Ms. Azra Sultana ", "043935024"); theList.insertFirst(5, "08120014", "Ms. Ruchi Tuli ", "043258088"); theList.insertFirst(4, "08120014", "Ms. Fozia Noor ", "043258088"); theList.insertFirst(3, "08120014", "Ms. Kajal nusratullah ", "043258088"); theList.insertFirst(2, "08120014", "Ms.Anusuyah Subbarao ", "043935024"); theList.insertFirst(1, "08120014", "Ms. Aizal Yusrina ", "043258088"); } public void mainUser(int ConvOption1,String Option1) { while(ConvOption1!=6) { switch (ConvOption1) // 5 cases { case 1: { theList.displayList(); System.out.println("---------------------------------------------------------------------------\n"); } break; case 2: { // Option1 = JOptionPane.showInputDialog("Enter how MANY TEACHERS U WANT TO FIND"); // a = Integer.parseInt(Option1); System.out.println("Enter how MANY TEACHERS U WANT TO FIND"); a=input.nextInt(); //theList. display1() ; for(int j=1;j<=a;j++) { // Option1 = JOptionPane.showInputDialog("\nEnter Number of Teacher Room ÏÏ "+j+" ÏÏ "); // b = Integer.parseInt(Option1); System.out.println("\nEnter Number of Teacher Room ÏÏ "+j+" ÏÏ "); b=input.nextInt(); f = theList.find( b); // find item if( f != null) { System.out.println("\nTEACHER NAME IS: "+f.Teacher_Name+"\nTEACHER ID: "+f.teacher_ID+"\nPHONE NUMBER IS: "+f.Phone_number); // JOptionPane.showMessageDialog(null,"\nTEACHER NAME IS: "+f.Items+"\nTEACHER ID: "+f.qui+"\nPHONE NUMBER IS: "+f.price); // System.out.println("\nQuintity of "+f.Items+" Now is "+e); } else { System.out.println("we did FOUND "+f.Teacher_Name); } } // System.out.println("\n ÒÒ price ="+t); System.out.println("---------------------------------------------------------------------------\n"); } break; case 3: { System.out.println("Enter THE ROOM NUMBER OF TEACHER "); int key=input.nextInt(); Link i = theList.delete(key); // delete item if( i != null ) { System.out.println("Deleted NUMBER OF ROOM : "+ i.Room_Number+"\n"); System.out.println("Delet the ID : "+i.teacher_ID +"\n"); System.out.println("Delet the Name Of TEACHER : "+ i.Teacher_Name+"\n" ); System.out.println("Delet the PHONE NUMBER : "+i.Phone_number+"\n"); System.out.println("SUCCESSFUL DELET"); } else { System.out.println("Can't delete "); System.out.println("the data still in list "+i); } System.out.print("---------------------------------------------------------------------------\n"); } break; case 4: { theList.display2(); System.out.println("Enter ROOM NUMBER:>"); key= input.nextInt(); Link i = theList.delete(key); System.out.print("---------------------------------------------------------------------------"); System.out.println("\nlist after EDIT:>"); theList.display2(); System.out.println("---------------------------------------------------------------------------\n"); } break; case 5: { theList.display2(); System.out.println("Enter New Teacher Room NUMBER:>"); key= input.nextInt(); Link i = theList.insertLast(key); System.out.print("---------------------------------------------------------------------------"); System.out.println("\nlist after EDIT:>"); theList.display2(); System.out.println("---------------------------------------------------------------------------\n"); } break; }//end switch if(ConvOption1>6) { JOptionPane.showMessageDialog(null, "YOUAR INPUT NUMBER NOT IN THE LIST\n PLEASE, TRY AGAIN"); } Option1 = JOptionPane.showInputDialog("\n1-Show List of TEACHERS\n2-SEARCH \n3-Remove \n4-Borrow\n5-Return\n6-Exit"); ConvOption1 = Integer.parseInt(Option1); }//end while } }//end mainUser method Link class class Link { public int Room_Number; public String teacher_ID; public String Teacher_Name; public String Phone_number; // data item public Link next; // next link in list // ------------------------------------------------------------- public Link(int a, String b, String teacher, String Phone) // constructor { Room_Number = a; teacher_ID = b; // constructor Teacher_Name = teacher; Phone_number = Phone; } // set to null) // ------------------------------------------------------------- public void displayLink1() // display ourself { System.out.println("\t" + Teacher_Name + "\t\t{" + Room_Number + "}"); System.out.println(""); } public void displayLink2() // display ourself { System.out.print("\t" + Room_Number); System.out.print("\t" + teacher_ID); System.out.print("\t" + Teacher_Name); System.out.println("\t\t{" + Phone_number + "}"); } } linkList class class linkList { private Link first; // ref to first link on list // ------------------------------------------------------------- public linkList() // constructor { first = null; // no links on list yet } // ------------------------------------------------------------- public boolean isEmpty() // true if list is empty { return (first == null); } // ------------------------------------------------------------- // insert at start of list public String insertFirst(int a, String SD, String teacher, String Phone) { // make // new // link Link newLink = new Link(a, SD, teacher, Phone); newLink.next = first; // newLink --> old first first = newLink; // first --> newLink return first.Room_Number + " " + first.teacher_ID + " " + first.Teacher_Name + "{" + first.Phone_number + "}"; } // ------------------------------------------------------------- public Link find(int key) // find link with given key { // (assumes non-empty list) Link current = first; // start at 'first' while (current.Room_Number != key) // while no match, { if (current.next == null) // if end of list, return null; // didn't find it else // not end of list, current = current.next; // go to next link } return current; // found it } // ///////////////////////////////////// public Link delete(int key) // delete link with given key { // (assumes non-empty list) Link current = first; // search for link Link previous = first; while (current.Room_Number != key) { if (current.next == null) return null; // didn't find it else { previous = current; // go to next link current = current.next; } } // found it if (current == first) // if first link, first = first.next; // change first else // otherwise, previous.next = current.next; // bypass it return current; } // ------------------------------------------------------------- public void insertLast( int key) { Link newLink = new Link(key); // make new link if( isEmpty() ) // if empty list, first = newLink; // first --> newLink else { last.next = newLink; // old last --> newLink newLink.previous = last; // old last <-- newLink } last = newLink; // newLink <-- last } // ------------------------------------------------------------- public void displayList() { System.out.println("\t\t\n\n *~...~* Welcome *~...~*\n\n "); System.out.print("\n\n\t\t The Menue \n\n"); System.out.println("\n\t :: NAME OF TEACHERS ::\t\t:: NUMBER OF ROOM ::"); System.out.println(""); Link current = first; // start at beginning of list while (current != null) // until end of list, { current.displayLink1(); // print data current = current.next; // move to next link } System.out.println(""); } public void display2() { System.out.print("\t\t *~...~* The Menue *~...~* \n\n"); System.out.println("\n\tR.N. ID TEACHER NAME \t PHONE NUMBER\n "); Link current = first; // start at beginning of list while (current != null) // until end of list, { current.displayLink2(); // print data current = current.next; // move to next link } System.out.println(""); } // ------------------------------------------------------------- } // end class LinkList
  9. تصحيح كود ( تحديد اللغة ) language Recognizer

    هذا الكود بعد اخر تعديل . import java.util.Scanner; class Stack { private int top = -1; private char stack[] = new char[10]; public void push(char a) { stack[++top] = a; } public char pop() { return (char) stack[top--]; } public void refill() { top = stack.length - 1; } public void reset() { top = -1; } } public class Class1 { public static void main(String[] args) throws Exception { Stack s1 = new Stack(); Stack s2 = new Stack(); Stack s3 = new Stack(); boolean isPartOf = false; Scanner input = new Scanner(System.in); int n, r = 0; char ch, ch1, ch2; System.out.println("========================================================================= "); System.out.println("Enter 10 letters for the language , , , WITHOUT SPACES BETWEEN THE LETTERS"); for (int i = 0; i < 10; i++) { ch = (char) System.in.read(); s1.push(ch); } System.out.println("========================================================================= "); System.out.println("The valid characters of your language are:"); for (int i = 0; i < 10; i++) { System.out.print(i + 1); System.out.println(") "); } System.out.println("========================================================================= "); System.out.println("Enter the number of the letters of the word you want to check"); n = input.nextInt(); System.out.println("========================================================================= "); System.out.println("Enter the word you need to check"); for (int i = 0; i < n; i++) { ch = (char) System.in.read(); s2.push(ch); } for (int i = 0; i < n; i++) { ch1 = s2.pop(); s1.refill(); for (int j = 0; j < 10; j++) { ch2 = s1.pop(); if (ch1 == ch2) { isPartOf = true; r++; s3.push(ch2); System.out.println("ch2 = " + ch2); } else if (isPartOf) { isPartOf = false; break; } } } if (isPartOf) { System.out.println("========================================================================= "); System.out.println("The word is part of the language\n"); } else { System.out.println("========================================================================= "); System.out.println("The word is not a part of the langauge\n"); } } } للاسف لا يعمل بكل الحالات :(
  10. تصحيح كود ( تحديد اللغة ) language Recognizer

    شكراااااُ على تعديل الكود جزاكم الله خير
  11. تصحيح كود ( تحديد اللغة ) language Recognizer

    لانه عندنا 3 ستاك بالكود ة حددت له في اي ستاك راح يعمل بوش و اي ستاك يعمل بوب خطأ كدا ؟؟ ---------------------------- مشروع المادة مطلوب بس هذا البرنامج و هذي المواضيع الثانية للمشاريع https://www.dropbox.com/s/zxm6138zpbvry83/20120905_192742.jpg?m و https://www.dropbox.com/s/9z1eqlbit2fw7a2/20120905_192753.jpg?m
  12. تصحيح كود ( تحديد اللغة ) language Recognizer

    السلام عليكم و رحمة الله عندي لمشروع مادة الداتا ستركشر المطلوب عمل هذا البرنامج و هذا الكود للبرنامج اششتغل تمام كل المطلوب ما عادا اخر مطلوب من السؤال اللي هوا مقارنة حروف اللغة المدخلة مع حروف الكلمة المدخلة هذا الكود import java.util.Scanner; import java.io.*; public class Class1 { int top=-1; char stack[]=new char[10]; public static void push(Class1 s , char a) { s.top++; s.stack[s.top]=a; } public static char pop(Class1 s) { char a; a=s.stack[s.top]; s.top--; return (a); } public static void main (String[]args) throws Exception { Class1 s1=new Class1(); Class1 s2=new Class1(); Class1 s3=new Class1(); Scanner input =new Scanner(System.in); char z; int a,a1,n,r=0; char ch,ch1,ch2; System.out.println("========================================================================= "); System.out.println("Enter 10 letters for the language , , , WITHOUT SPACES BETWEEN THE LETTERS"); for(int i=0;i<10;i++) { ch=(char) System.in.read(); s1.push(s1,ch); } System.out.println("========================================================================= "); System.out.println("The valid characters of your language are:"); for(int i=1;i<=10;i++) { System.out.print(i); System.out.print(") "); System.out.println( s1.pop(s1)); } System.out.println("========================================================================= "); System.out.println("Enter the number of the letters of the word you want to check"); n=input.nextInt(); ch=(char)System.in.read(); n=n-10; System.out.println("========================================================================= "); System.out.println("Enter the word you need to check"); for(int i=0;i<10;i++) { ch=(char) System.in.read(); s2.push(s2,ch); } for(int i=0;i<n;i++) { ch1=s2.pop(s2); for(int j=0;j<n;j++) { ch2=s1.pop(s1); if(ch1==ch2) r++; s3.push(s3,ch2); } } if(r==n) { System.out.println("========================================================================= "); System.out.println("The word is part of the language"); } else { System.out.println("========================================================================= "); System.out.println("The word is not a part of the langauge"); } } } و هذا الاوت بوت المشكلة محددة بالخط الاحمر لما ادخلت حروف من ضمن اللغة اللي ادخلتها يطلع انه not a part
  13. شيكو لي على اجابات واجبي

    Question 6 Solve the following problem by using BFS, DFS & UCS. Find out the optimal path and show the fringe at each step اولاً الحل باستخدام BFS Fringe : A Fringe : C B A Fringe : B A G So the algorithm return the path S C G صح كدا ؟؟ و لا لازم يكون القول بداية الرينج ؟
  14. شيكو لي على اجابات واجبي

    الاستاذة ارفقت لنا ملف يساعدنا بالاسايمنت بس هوا كتاب مسنكر و الخط مو واضح بالنسبة للفقرة الاولى من السؤال الثاني متاكدة منه ان شاء الله اما بالنسبة للفقرات التالية اولا لازم افهم معناه بالعربي كويس 2. An auto car mechanic agent . هذا معناه سيارة ذاتية الحركة ؟؟؟ 3. An agent to handle phone Inquiry هذا معناه ايجنت يشتغل بالرد الالي ؟؟ 4. Agent bidding on an item in an auction هذا معناه ايجنت يشتغل بالمزاد العلني ؟؟ الصراحة هذا الجزء من الشبتر اللي هوا type of agent architecture مني فاهمته كويس و لذلك عندي مشكلة