ברוכים הבאים לאתר השאלות והתשובות. מקום בו תוכלו לשאול כל שאלה ולקבל תשובות מהקהילה. יצירת קשר במייל aviboots(AT)netvision.net.il

התגיות הפופולריות ביותר

c#

כיצד מחליפים בין שני מספרים

0 אהבו 0 לא אהבו
106 views
asked Oct 27, 2013 in C# תכנות על-ידי avibootz (3,230 נקודות)

תשובה אחת

0 אהבו 0 לא אהבו

using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            //example 1
            int a = 3, b = 12;

            Console.WriteLine("a = {0}, b = {1}", a, b);
            swap(ref a, ref b);
            Console.WriteLine("a = {0}, b = {1}", a, b);

            //example 2
            int c = 19, d = 7;

            Console.WriteLine("\nc = {0}, d = {1}", c, d);
            c = c + d;
            d = c - d;
            c = c - d;
            Console.WriteLine("c = {0}, d = {1}", c, d);

        }
        static void swap(ref int x, ref int y)
        {
            int tmp;

            tmp = x;
            x = y;
            y = tmp;
        }
    }
}

Care הסרת משקפי ראיה וקריאה

answered Oct 27, 2013 על-ידי avibootz (3,230 נקודות)
...