קהילות פורומים, הורדות, יעוץ ותמיכה


אשכולות דומים

  1. [פריקה] בעייה מעצבנת
    על ידי משתמש אנונימי בפורום מתבגרים ומתגברים
    תגובות: 4
    הודעה אחרונה: 14-12-2011, 22:41
  2. [XP - בעיה נפתרה] בעייה ב java
    על ידי nati_98 בפורום תמיכה טכנית
    תגובות: 3
    הודעה אחרונה: 19-11-2011, 22:19
  3. [עזרה] תוכנית ב JAVA
    על ידי Nostlgia בפורום האקינג ואבטחת מידע
    תגובות: 2
    הודעה אחרונה: 28-12-2009, 16:35
  4. [בעייה] מעצבנת בפיירפוקס 3.5
    על ידי Maryum375 בפורום תמיכה טכנית
    תגובות: 5
    הודעה אחרונה: 16-07-2009, 03:33
  5. [בעייה] FIFA 2006 DEMO
    על ידי AtRaF MaN בפורום תמיכה טכנית במשחקים
    תגובות: 0
    הודעה אחרונה: 07-09-2005, 18:44
+ תגובה לנושא
מציג תוצאות 1 עד 4 מתוך 4

בעייה מעצבנת :D תוכנית ב C# ו JAVA למציאת מיקום בstring

  1. #1
    משתמש כבוד האוואטר של Someone Awesome
    שם פרטי
    עידו
    תאריך הצטרפות
    09/2008
    הודעות
    11,867
    לייקים
    3
    נקודות
    806
    משפט מחץ
    Software is like sex, it's better when it's free. - Linus Torvalds
    מין: זכר

    ברירת מחדל בעייה מעצבנת :D תוכנית ב C# ו JAVA למציאת מיקום בstring


    החוט לדוגמא זה רק זה - דוגמא.

    אתם יכולים לנסות ולראות שלא תמיד יוצא (כשהוא חושב שהחוט לא נמצא שם הוא פולט מס' שלישי, בד"כ -220).

    זה בעצם מוצא את המיקום של חוט ב' בחוט א'.

    כלומר:
    החוט "שלום" נמצא במיקום ה8 בחוט " דני אמר שלום לחנה".

    אני מניח שאתם מבינים, בטח גם יש פונקציה מוכנה לזה אבל רציתי לבנות אחת בעצמי כאימון.



    טוב, עכשיו אני מתבישש בתהליך בדיקה העלוב שעשיתי לו...
    קוד בתיקון, נראה מה אני אצליח לסדר ,
    תוקן - עדיין לא עובד.


    קוד:
    //using System; //using System.Collections.Generic; //using System.Linq; //using System.Text; public class Main { public static int charver(String Kstr, String Sstr, int counter, int loc) { if (counter >= Sstr.length() ) { return -220; } for (int i = counter; i < Sstr.length() ; i++) { if (Kstr.charAt(loc) == Sstr.charAt(i) ) { return i; } } return -220; } public static int isat(String Kstr, String Sstr, int counter) { int i; int ret = -220; int checkme; if (charver(Kstr, Sstr, counter, 0) > 0) { checkme = charver(Kstr, Sstr, counter, 0)-1; ret = charver(Kstr, Sstr, counter, 0); } else { return -220; } for (i = 0; i < Kstr.length(); i++) { if (i == Kstr.length() - 1 && charver(Kstr, Sstr, counter, i) == checkme + 1) { return ret; } if (charver(Kstr, Sstr, counter, i) == checkme + 1) { checkme = charver(Kstr, Sstr, counter, i); } else if (charver(Kstr, Sstr, counter, i) > checkme + 1) { counter = ret + 1; i = 0; return isat(Kstr, Sstr, counter); } else if (charver(Kstr, Sstr, counter, i) < 0) { return -220; } else if (charver(Kstr, Sstr, counter, i) < checkme + 1) { counter = ret + 1; i = 0; return isat(Kstr, Sstr, counter); } } return -220; } public static void main (String[]args) { String A = " An airport is a location where aircraft such as fixed-wing aircraft, helicopters, and blimps take off and land. Aircraft may be stored or maintained at an airport. An airport consists of at least one surface such as a runway, a helipad, or water for takeoffs and landings, and often includes buildings such as hangars and terminal buildings.Larger airports may have fixed base operator services, seaplane docks and ramps, air traffic control, passenger facilities such as restaurants and lounges, and emergency services. A military airport is known as an airbase or air station. The terms airfield, airstrip, and aerodrome may also be used to refer to airports, and the terms heliport, seaplane base, and STOLport refer to airports dedicated exclusively to helicopters, seaplanes, or short takeoff and landing aircraft. In some jurisdictions, the term airport is used where the facility is licensed as such by the relevant government organization (e.g. the U.S. Federal Aviation Administration (FAA), Transport Canada). Elsewhere the distinction is one of general appearance. Other jurisdictions define an airport by its having the customs offices etc expected of a port,[citation needed] though the more general term is airport of entry."; String B = "land"; int loc1 = charver(B, A, 0, 0); int loc = isat(B, A, 0); // Console.WriteLine(loc); // Console.WriteLine(loc1); // Console.ReadKey(); System.out.println("Ais: "+loc1+ " Bis: "+loc); } }
    הנה ב C# למי שלא מסתדר עם JAVA :
    קוד:
    using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { public class Hello { public static int charver(String Kstr, String Sstr, int counter, int loc) { if (counter >= Sstr.Length) { return -220; } for (int i = counter; i < Sstr.Length; i++) { if (Kstr[loc] == Sstr[i]) { return i; } } return -220; } public static int isat(String Kstr, String Sstr, int counter) { int i; int ret = -220; int checkme; if (charver(Kstr, Sstr, counter, 0) > 0) { checkme = charver(Kstr, Sstr, counter, 0)-1; ret = charver(Kstr, Sstr, counter, 0); } else { return -220; } for (i = 0; i < Kstr.Length; i++) { if (i == Kstr.Length - 1 && charver(Kstr, Sstr, counter, i) == checkme + 1) { return ret; } if (charver(Kstr, Sstr, counter, i) == checkme + 1) { checkme = charver(Kstr, Sstr, counter, i); //Console.WriteLine("CCCheck me:" + checkme); } else if (charver(Kstr, Sstr, counter, i) > checkme + 1) { counter = ret +1; i = 0; //Console.WriteLine("CCCheck me:" + checkme); return isat(Kstr, Sstr, counter); } else if (charver(Kstr, Sstr, counter, i) < 0) { return -220; } else if (charver(Kstr, Sstr, counter, i) < checkme + 1) { counter = ret +1 ; i = 0; //Console.WriteLine("Counter:" + counter); return isat(Kstr, Sstr, counter); } } return -220; } static void Main(string[] args) { String A = " An airport is a location where aircraft such as fixed-wing aircraft, helicopters, and blimps take off and land. Aircraft may be stored or maintained at an airport. An airport consists of at least one surface such as a runway, a helipad, or water for takeoffs and landings, and often includes buildings such as hangars and terminal buildings.Larger airports may have fixed base operator services, seaplane docks and ramps, air traffic control, passenger facilities such as restaurants and lounges, and emergency services. A military airport is known as an airbase or air station. The terms airfield, airstrip, and aerodrome may also be used to refer to airports, and the terms heliport, seaplane base, and STOLport refer to airports dedicated exclusively to helicopters, seaplanes, or short takeoff and landing aircraft. In some jurisdictions, the term airport is used where the facility is licensed as such by the relevant government organization (e.g. the U.S. Federal Aviation Administration (FAA), Transport Canada). Elsewhere the distinction is one of general appearance. Other jurisdictions define an airport by its having the customs offices etc expected of a port,[citation needed] though the more general term is airport of entry."; String B = "land"; int loc1 = charver(B, A, 0, 0); int loc = isat(B, A, 0); Console.WriteLine(loc); Console.WriteLine(loc1); Console.ReadKey(); } } }
    עכשיו זה עובד לפעמים (על חלק מהדברים שמחפשים), בד"כ לא.
    נערך לאחרונה על ידי Someone Awesome; 14-02-2010 בשעה 21:25.

    ציטוט נכתב במקור על ידי Michael. צפיה בהודעה
    אם היא דלוקה עלייך אז היא גם נמשכת אלייך >.<"



    Amd Phenom 2 X2 550 3.1GHZ @ 3.5GHZ
    Gigabyte MA770-UD3
    Powercolor Ati Raedon HD 4870 512Mb
    A-data 4 Gb (2x2) 800MHZ vitesta
    Samsung 500GB
    Antec two hundred
    Seasonic ss500-ET

  2. קישורים ממומנים

  3. #2
    משתמש משקיע האוואטר של lir the king
    שם פרטי
    ליר
    תאריך הצטרפות
    04/2009
    הודעות
    2,997
    לייקים
    1
    נקודות
    9
    משפט מחץ
    קטן קטן,אבל נכנס לכל חור
    מין: זכר

    ברירת מחדל

    מה לא עובד לך?
    בדקתי וזה היה בסדר..

  4. #3
    משתמש כבוד האוואטר של Someone Awesome
    שם פרטי
    עידו
    תאריך הצטרפות
    09/2008
    הודעות
    11,867
    לייקים
    3
    נקודות
    806
    משפט מחץ
    Software is like sex, it's better when it's free. - Linus Torvalds
    מין: זכר

    ברירת מחדל

    תנסה עם כמה דברים...
    לפעמים יש דברים שקיימים והוא אומר שהם לא נמצאים שם.

    ציטוט נכתב במקור על ידי Michael. צפיה בהודעה
    אם היא דלוקה עלייך אז היא גם נמשכת אלייך >.<"



    Amd Phenom 2 X2 550 3.1GHZ @ 3.5GHZ
    Gigabyte MA770-UD3
    Powercolor Ati Raedon HD 4870 512Mb
    A-data 4 Gb (2x2) 800MHZ vitesta
    Samsung 500GB
    Antec two hundred
    Seasonic ss500-ET

  5. #4
    משתמש כבוד האוואטר של Someone Awesome
    שם פרטי
    עידו
    תאריך הצטרפות
    09/2008
    הודעות
    11,867
    לייקים
    3
    נקודות
    806
    משפט מחץ
    Software is like sex, it's better when it's free. - Linus Torvalds
    מין: זכר

    ברירת מחדל

    מצאתי את הפתרון!!!
    הוספה של שורה אחת בתחילת לולאת ה FOR:
    קוד:
     counter = checkme + 1;
    היה צריך להוסיף אותה כדי שלא יווצר מצב כמו שהיה נוצר פה:
    mary had a little lamb and a big giant deer
    נגיד והייתי מחפש:
    deer
    אז בהתחלה הוא היה מוצא את ה d הראשונה. במיקום 8.
    הd הזאת לא טובה, אז הוא היה מתחיל את הפונקציה מחדש ( recursive function) ברווח שבין had לa.
    שם ה d הראשונה הייתה באמת במילה deer, אבל הe הראשונה הייתה קודם - אז הוא היה מתחיל את הפונקציה בe השנייה של הdeer וכבר לא מוצא את המילה deer.

    לכן, הגדרתי לו שהמונה (counter) יתחיל לחפש כל פעם מההתאמה האחרונה, ולא ילך אחורה.

    טוב, לומדים מטעויות.


    ציטוט נכתב במקור על ידי Michael. צפיה בהודעה
    אם היא דלוקה עלייך אז היא גם נמשכת אלייך >.<"



    Amd Phenom 2 X2 550 3.1GHZ @ 3.5GHZ
    Gigabyte MA770-UD3
    Powercolor Ati Raedon HD 4870 512Mb
    A-data 4 Gb (2x2) 800MHZ vitesta
    Samsung 500GB
    Antec two hundred
    Seasonic ss500-ET

+ תגובה לנושא


הרשאות פרסום

  • אין באפשרותך לפרסם נושאים חדשים
  • אין באפשרותך לפרסם תגובות
  • אין באפשרותך לצרף קבצים
  • אין באפשרותך לערוך את הודעותיך


כל הזמנים הם לפי GMT +3. השעה כרגע היא 19:16.
מופעל על ידי vBulletin™ © גרסה 4.1, 2011 vBulletin Solutions, Inc. כל הזכויות שמורות.
פעילות הגולשים
אומנות וגרפיקה
מוזיקה
ספורט
סדרות טלוויזיה
סרטים וקולנוע
קנייה ומכירה
רשתות חברתיות
הבורר 3
פורומי פנאי ובידור
סרטים
סדרות
משחקים
דיבורים
אקטואליה
בעלי חיים
בדיחות והומור
משחקי ספורט
הבורר
מחשבים וטכנולוגיה
תמיכה טכנית
חומרה ומודינג
תוכנות להורדה
סלולארי וגאדג'טים
רקעים למחשב
ציוד הקפי למחשב
אבטחת מידע
תכנות ובניית אתרים
כסף ברשת
אייפון
בריאות ואורח חיים
כושר ופיתוח גוף
דיאטה
צבא וגיוס
יעוץ מיני
מה שבלב
אומנות הפיתוי
יהדות
מיסטיקה ורוחניות
אתאיזם ודתות

נושאים: 2,473,855 | הודעות: 8,174,442 | משתמשים: 315,603 | המשתמש החדש ביותר: upizijoj | עיצוב גרפי: סטודיו עודד בביוף | קידוד: rellect