שיחה:שלום לאמונות

תוכן הדף אינו נתמך בשפות אחרות.
מתוך ויקיפדיה, האנציקלופדיה החופשית

את האורך הכולל של האלבום חישבתי באמצעות הקוד הבא:

using System; using System.Collections.Generic; using System.Text;

namespace MathKnight.Time01 {

   class Program
   {
       static void Main(string[] args)
       {
           // Test 
           Time test1 = new Time(0,10,25);
           Time test2 = new Time(0, 55, 41);
           Console.WriteLine(test1.ToString());
           Console.WriteLine("+");
           Console.WriteLine(test2.ToString());
           Time test3 = test1 + test2;
           Console.WriteLine("=");
           Console.WriteLine(test3.ToString() + "\n");
           
           // Shalom LaEmunot - Miri Mesika
           Time[] times = new Time[14];
           times[0] = new Time(0, 4, 24);
           times[1] = new Time(0, 4, 5);
           times[2] = new Time(0, 3, 22);
           times[3] = new Time(0, 3, 42);
           times[4] = new Time(0, 4, 1);
           times[5] = new Time(0, 4, 2);
           times[6] = new Time(0, 3, 8);
           times[7] = new Time(0, 4, 55);
           times[8] = new Time(0, 3, 53);
           times[9] = new Time(0, 3, 27);
           times[10] = new Time(0, 3, 52);
           times[11] = new Time(0, 4, 4);
           times[12] = new Time(0, 4, 7);
           times[13] = new Time(0, 3, 52);
           Time sum = new Time(0, 0, 0);
           for (int i = 0; i < 14; i++)
           {
               sum += times[i];
           }
           Console.WriteLine("Duration sum = " + sum.ToString());
           Console.ReadKey();
       }
   }
   class Time
   {
       public uint hours;
       public ushort minutes;
       public ushort seconds;
       // constructor
       public Time(uint h, ushort m, ushort s)
       {
           this.hours = h;
           this.minutes = m;
           this.seconds = s;
       }
       // output
       public override string  ToString()
       {
           string s = ""+ this.hours;
           if (this.minutes < 10)
               s += ":0" + this.minutes;
           else
               s += ":" + this.minutes;
           if (this.seconds < 10)
               s += ":0" + this.seconds;
           else
               s += ":" + this.seconds;
               
            return s;
       }
       // operator overload
       public static Time operator +(Time lhs, Time rhs)
       {
           Time result = new Time(0,0,0);
           // seconds
           if (lhs.seconds + rhs.seconds < 60)
               result.seconds = (ushort)(lhs.seconds + rhs.seconds);
           else
           {
               result.seconds = (ushort)(lhs.seconds + rhs.seconds - 60);
               result.minutes = 1;
           }
           // minutes
           if (lhs.minutes + rhs.minutes < 60)
               result.minutes += (ushort)(lhs.minutes + rhs.minutes);
           else
           {
               result.minutes += (ushort)(lhs.minutes + rhs.minutes - 60);
               result.hours = 1;
           }
           // hours
           result.hours += lhs.hours + rhs.hours;
           return result;
       } //end +
   } // end class

}


שכתבתי ב-C#. מסיקה, אגב, נראית נפלא וגם שרה יפה. בברכה, MathKnight הגותי |Δ| (שיחה) 17:45, 23 בפברואר 2007 (IST)[תגובה]

מי בעד שמירי מסיקה תהפוך לסולנית בלהקת מטאל גותי?

  1. בעד בברכה, MathKnight הגותי |Δ| (שיחה) 21:10, 23 בפברואר 2007 (IST)[תגובה]
  2. בעד --Andrei 22:49, 11 במרץ 2007 (IST)[תגובה]
  3. בעד לגמרי. Shefshef : השיחה והחזון 13:19, 19 בנובמבר 2009 (IST)[תגובה]