פורסם 2009 במרץ 1216 שנים אני יושב עליה כבר יותר משעה. ניסתי לפתור לבד ולא הצלחתי זה מה שהצלחתי: int num_of_players; int rolling; int zover_while=0; char stoping; Console.Write("Enter the number of the playeres: "); num_of_players = int.Parse(Console.ReadLine()); string[] color = new string[num_of_players]; for (int i = 0; i < num_of_players; i++) { Console.Write("Player number {0} enter color: ", i + 1); color[i] = (Console.ReadLine()); }//for stoping=char.Parse (Console.ReadLine()); while (stoping != 'Q') { zover_while++; stoping = char.Parse(Console.ReadLine()); } int[] roll = new int[zover_while]; for(int i=0;i<zover_while;i++) { Random rnd = new Random(); rolling= rnd.Next(1, num_of_players + 1); roll[rolling]++; } ואני לא יודע איך להציג את השם של הצבע עם ההכי הרבה הגרלות. ניסתי כמה דברים וזה לא עבד למרות שנראה לי שהייתי ממש קרוב. אשמח לעזרה ואם אפשר גם הסבר זה בכלל מבורך לילה טוב ותודה מראש [attachment deleted by admin]
פורסם 2009 במרץ 1216 שנים הכרזת על האובייקט rnd כל פעם מחדש, זו טעות, הפתרון שלך דיי בסדר, רק כמה שינויים מרכזיים:int num_of_players;int rolling;int zover_while=0;int maxPosition; //יכיל את האינדקס של הצבע שהוגרל הכי הרבה פעמיםRandom rnd = new Random(); char stoping;Console.Write("Enter the number of the playeres: ");num_of_players = int.Parse(Console.ReadLine());int[] roll = new int[num_of_players];string[] color = new string[num_of_players];for (int i = 0; i < num_of_players; i++){ roll[i] = 0; //הוספת איפוס Console.Write("Player number {0} enter color: ", i + 1); color[i] = (Console.ReadLine());}//forstoping=char.Parse (Console.ReadLine());while (stoping != 'Q'){rolling = rnd.Next(0, num_of_players - 1);roll[rolling]++; //הגדלת מונה ההגרלות של אותו צבעstoping = char.Parse(Console.ReadLine());}maxPosition = 0;for(i = 1; i < num_of_players; i++){if(roll[i] > roll[maxPosition]) maxPosition = i;}Console.WriteLine("The Winning Color is " + color[maxPosition]);בגדול מה שחשוב פה זה עבודה במקביל עם שני מערכים - אחד של צבעים, מערך מטיפוס מחרוזת, והשני - מטיפוס שלם, שימנה הגרלות עבור הצבעים.
פורסם 2009 במרץ 1216 שנים Hardstyler אתה יכול לנסות לעזור גם לי קצת? בבקשה.http://hwzone.co.il/community/index.php?topic=398520.0
פורסם 2009 במרץ 1216 שנים Hardstyler אתה יכול לנסות לעזור גם לי קצת? בבקשה. http://hwzone.co.il/community/index.php?topic=398520.0 מצטער, לא בדיוק מבין מה הולך שם, אני עוד בחומר של כיתה י'
פורסם 2009 במרץ 1216 שנים מחבר תודה רבה Hardstyler ! עשיתי משהו ממש דומה למה שאתה רשמת בסוף אבל אצלי זה לא פעל
ארכיון
דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.