/* קלט: רשימת אורכי 100 השירים במכשיר MP3 פלט: מספרו של השיר הארוך היותר, ומספרו של השיר הקצר ביותר */ using System; public class Mp3 { public static void Main() { const int NUM_OF_SONGS = 100; //הגדרת קבוע – מספר השירים בנגן double currentSongLength; //אורך השיר הנוכחי double shortest; // אורך השיר הקצר ביותר double longest; // אורך השיר הארוך ביותר int placeLongest, placeShortest; //מיקומם של השיר הקצר והארוך Console.Write("Enter the length of the first song: "); currentSongLength = double.Parse(Console.ReadLine()); //אתחולם של המקסימום, המינימום ומקומם longest = currentSongLength; shortest = currentSongLength; placeLongest = 1; placeShortest = 1; // הלולאה מתחילה מ-2 כיוון שהשיר הראשון כבר נקלט for (int i = 2; i <= NUM_OF_SONGS; i++) { Console.Write("Enter the length of song {0}: ", i); currentSongLength = double.Parse(Console.ReadLine()); if (currentSongLength > longest) { longest = currentSongLength; placeLongest = i; } // if if (currentSongLength < shortest) { shortest = currentSongLength; placeShortest = i; } // if } // for Console.WriteLine("The number of the longest song is {0}", placeLongest); Console.WriteLine("The number of the shortest song is {0}", placeShortest); } // Main }// Mp3