1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
tamaranim1 [39]
3 years ago
13

#include

Computers and Technology
1 answer:
rodikova [14]3 years ago
7 0

Output

SORTED                                                                                                                                

4 7 10 69                                                                                                                              

                                                                                                                                     

SORTED                                                                                                                                

10 9 7 3                                                                                                                              

                                                                                                                                     

NOT SORTED                                                                                                                            

19 12 23 7                                                                                                                            

                                                                                                                                     

SORTED                                                                                                                                

5 5 5 5

Code

//The added part is in the bottom

#include <iostream>

using namespace std;

const int SIZE = 4;

bool isSorted (const int arr[], int size);

bool isNonDecreasing (const int arr[], int size);

bool isNonIncreasing (const int arr[], int size);

void printArr (const int arr[], int size);

int

main ()

{

 int test1[] = { 4, 7, 10, 69 };

 int test2[] = { 10, 9, 7, 3 };

 int test3[] = { 19, 12, 23, 7 };

 int test4[] = { 5, 5, 5, 5 };

 if (!isSorted (test1, SIZE))

   cout << "NOT ";

 cout << "SORTED" << endl;

 printArr (test1, SIZE);

 if (!isSorted (test2, SIZE))

   cout << "NOT ";

 cout << "SORTED" << endl;

 printArr (test2, SIZE);

 if (!isSorted (test3, SIZE))

   cout << "NOT ";

 cout << "SORTED" << endl;

 printArr (test3, SIZE);

 if (!isSorted (test4, SIZE))

   cout << "NOT ";

 cout << "SORTED" << endl;

 printArr (test4, SIZE);

 return 0;

}

bool

isSorted (const int arr[], int size)

{

//Added part

 if (isNonDecreasing (arr, size) || isNonIncreasing (arr, size))

   {

     return true;

   }

 else

   {

     return false;

   }

}

bool

isNonDecreasing (const int arr[], int size)

{

 for (int i = 0; i < (size - 1); i++)

   {

     if (arr[i] > arr[i + 1]) //It compares the n value with the n-1 value and output

{

  return false;

  break;

}

   }

 return true;

}

bool

isNonIncreasing (const int arr[], int size)

{

 for (int i = 0; i < (size - 1); i++)

   {

     if (arr[i] < arr[i + 1]) //It compares the n value with the n-1 value and output reautilization of previous function by replacing only “<”

{

  return false;

  break;

}

   }

 return true;

}

void

printArr (const int arr[], int size)

{

 for (int i = 0; i < size; i++)

   cout << arr[i] << " ";

 cout << endl << endl;

}

You might be interested in
Find examples of conic sections in art and architecture. Visit Web sites to find pictures of artwork or buildings that illustrat
liubo4ka [24]

The question above wants to assess your interpretation of conic shapes and sections in art and architecture. For that reason, I can't write an answer for you, but I'll show you how to write it.

The conical sections can be seen in structures that assume one of the shapes considered conical. These formats are easy to identify, especially in architecture, where they are very popular. These shapes can be classified as Parabola, Circle, Ellipse, and Hyperbole

In this case, to write your answer, you should search for architectural works or works of art that present one of these types of conic sections and show how the use of this format is important for these works.

Some examples of works that use conic sections are:

  • Parabola: Eiffel Tower.
  • Circle: Farmer's Cottage Deluxe Summer House
  • Ellipse: Tycho Brahe Planetarium.
  • Hyperbole: McDonnell Planetarium

More information:

brainly.com/question/2285436

8 0
2 years ago
How would I collect a number from the user to use for the radius of a circle?
exis [7]

Answer:

C is the correct answer to your question

7 0
2 years ago
What is this error SyntaxError: Unexpected token '??='
vesna_86 [32]

Answer:

Occurs when a specific language construct was expected, but something else was provided.

6 0
2 years ago
Assume that word is a variable of type String that has been assigned a value. Assume furthermore that this value always contains
Valentin [98]

Answer:

   String word = "George slew the dragon";

   

   int pos = word.indexOf("dr");    

   String drWord = word.substring(pos, pos+4);

   

   System.out.println(drWord);

Explanation:

Assuming dr is always there, we don't have to check the validity of 'pos'. Normally, you would!

5 0
3 years ago
Read 2 more answers
Providing incentives for customers to learn more about your service is known as?
Julli [10]
B) Advertising is the answer
3 0
3 years ago
Other questions:
  • After doing the route tracing to a particular IP addresses, paste the path of IP addresses that were taken from your IP address
    13·1 answer
  • What kind of testing is basically checking whether a game or feature works as expected by the developers?
    10·1 answer
  • Which type of element is , and what is the meaning of that element?
    8·1 answer
  • You need to replace a broken monitor on a desktop system. You decide to replace it with a spare monitor that wasn't being used.
    15·2 answers
  • Which line of code will find the first occurrence of a three in an array?
    5·2 answers
  • PLEASE HELP I HAVE A TEST RIGHT NOW!!!
    13·1 answer
  • Document accurately describes the differences between servers and computers and between local and wide area networks. Document p
    5·1 answer
  • Which of the following statements is/are correct? a. At the network layer, entitlement can map identity and/or attributes to fun
    8·1 answer
  • The most serious security threat to Bluetooth-enabled devices is ____, which occurs when a hacker gains access to the device and
    10·1 answer
  • One rule in the Java programming language is that you have to place a semicolon at the end of each statement. What is this rule
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!