예제 #1
0
 public static int[] Increase(int[] arr)
 {
     for (int i = 0; i < arr.Length; i++)
     {
         int min = i;
         for (int j = i; j < arr.Length; j++)
         {
             if (arr[j] < arr[min])
             {
                 min = j;
             }
         }
         MyVariables.Swap(ref arr[i], ref arr[min]);
     }
     return(arr);
 }
예제 #2
0
        public static int SumOfDivisibleNum(int div, int left, int right)
        {
            int rep = 0;

            if (left > right)
            {
                MyVariables.Swap(ref left, ref right);
            }

            while (left <= right)
            {
                if (left % div == 0)
                {
                    rep += left;
                    //Console.Write(left + " ");               чтобы вывести промежуточные значения
                }
                left++;
            }
            return(rep);
        }
예제 #3
0
        public static int GreatestCommonFactor(int a, int b)
        {
            if (a < b)
            {
                int buf = a;
                a = b;
                b = buf;
            }

            while (b != 1)
            {
                if (a % b == 0)
                {
                    return(b);
                }
                a = a % b;
                MyVariables.Swap(ref a, ref b);
            }

            return(b);
        }