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
The dlci field in the frame relay header is _________ bits long.
ycow [4]
6 or 10-bit length

DLCI (Data Link Connection Identifier) is the essence of the Frame Relay Header. This value length represents the virtual connection between the DTE and the switch. The DLCI values are unique only to the physical channel on which they reside and thus, maintaining local significance only.



4 0
3 years ago
With which type of social engineering attack are users asked to respond to an email or are directed to a website where they are
kirza4 [7]

Answer:

Phishing

Explanation:

Phishing is a social engineering attack where users are asked to respond to an email or are directed to a website where they are requested to login with their personal credentials, such as passwords or credit card numbers.

How Phishing Works?

The attacker first carefully designs a web page identical to a real bank with fine details. Then attacker persuades the victim to go to this fake web page with login screen. The attacker gets all the information typed and enter into that fake web page. The victim often thinks that this is exactly my bank's web page so nothing is going to happen if I put log in credentials.

How to avoid Phishing?

This kind of attack can always be spotted with one simple trick. Check the address of the web page carefully. The attacker can design the web page according to his wish but he cannot have control over the web address of a real bank or real a website.  

Some general safety tips are:

  • Don't open links from spam emails.
  • Don't download malicious software.
  • Don't share personal information with strangers
7 0
3 years ago
What is the output?
olga55 [171]

Answer:

The output is 28

Explanation:

Required

Determine the output of the code segment

The first line initializes "answer" to 0

The next two lines iterate through lists [2,4] and [3,5

Each of these lists have two elements; So, the number of iterations is 2 * 2 i.e. 4.

In the first iteration

numA = 2, numB = 3, answer = 0

So:

answer = answer + numA + numB= 0 + 2 + 3 = 5

In the second iteration

numA = 2, numB = 5, answer = 5

So:

answer = answer + numA + numB= 5 + 2 + 5 = 12

In the third iteration

numA = 4, numB = 3, answer = 12

So:

answer = answer + numA + numB= 12 + 4 + 3 = 19

In the fourth iteration

numA = 4, numB = 5, answer = 19

So:

answer = answer + numA + numB= 19 + 4 + 5 = 28

Lastly, the value of "answer" is printed

<em>Hence, the output is 28</em>

7 0
3 years ago
I need the answer ASAP. I’ll mark brainliest if right
Kisachek [45]

Answer:

copy or repeat

Explanation:

7 0
2 years ago
Write a generator function named count_seq that doesn't take any parameters and generates a sequence that starts like this: 2, 1
-BARSIC- [3]

Answer:

#required generator function

def count_seq():

   #starting with number 2. using string instead of integers for easy manipulation

   n='2'

   #looping indefinitely

   while True:

       #yielding the integer value of current n

       yield int(n)

       #initializing an empty string

       next_value=''

       #looping until n is an empty string

       while len(n)>0:

           #extracting first digit (as char)

           first=n[0]

           #consecutive count of this digit

           count=0

           #looping as long as n is non empty and first digit of n is same as first

           while len(n)>0 and n[0]==first:

               #incrementing count

               count+=1

               #removing first digit from n

               n=n[1:]

           #now appending count and first digit to next_value

           next_value+='{}{}'.format(count,first)

       #replacing n with next_value

       n=next_value

#testing, remove if you don't need this

if __name__ == '__main__':

   #creating a generator from count_seq()

   gen=count_seq()

   #looping for 10 times, printing next value

   for i in range(10):

       print(next(gen))

Explanation:

6 0
3 years ago
Other questions:
  • Jill needs to create a chart for technology club that shows what percentage of total students in the school play video games. Wh
    11·2 answers
  • You often insert your company's logo into documents you create. One way to make it easier for you to quickly insert it is to sav
    10·1 answer
  • Define an I/O port. Which functions are performed by it?
    10·1 answer
  • This is a text message that is stored on a user's computer by a Web server that helps trace the user's browsing habits. a. Scrip
    14·1 answer
  • What are the five types of alignment in Word?
    12·2 answers
  • kieran wants to search a database quickly for information on the last time a patient came to his medical facility.The informatio
    14·2 answers
  • Two technicians are discussing a parasitic load test. Technician A says that the parasitic load is measured with an ammeter Tech
    13·1 answer
  • Which of the following transfer rates is the FASTEST?
    15·1 answer
  • Hurry im TIMED
    8·1 answer
  • How many different four-letter combinations for a locker password can you make with the lowercase and uppercase forms of the fir
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!