Respuesta :
Answer:
public static boolean isSorted(Comparable[] x, boolean y)
{
boolean isAscending = true;
if (x.length == 0 || x.length == 1) return true;
else if (y) {
for (int i = 0; isAscending && i < x.length - 1; i++)
if (x[i].compareTo(x[i + 1]) > 0) isAscending = false; // descending
} else {
for (int i = 0; isAscending && i < x.length - 1; i++)
if (x[i].compareTo(x[i + 1]) < 0) isAscending = false; // ascending
}
return isAscending;
}
Explanation:
See answer
Explanation:
Program:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace StaticMethods1
{
class comparable
{ p=small object, m=medium object, G=big object
public static comparable objects (int p, int m,g)
{
int s = p≤ m≤ g;
true;
}
public static int Subtract (int P, int M,int G)
{
int r = p≥m≥g ;
return r;
}
}
class Program
{
static void Main (string [] args)
{
Console.Write ("comparable p ≤ m is");
Console.WriteLine (comparable (p,≤ m));
Console.Write ("comparable m≤g is");
Console.WriteLine (comparable operacion (g≥m≥p));
Console.ReadKey ();