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
Harlamova29_29 [7]
3 years ago
15

Cerinţa Se dau două numere naturale nenule n și p. Afișați în ordine crescătoare puterile lui n mai mici sau egale cu p. Date de

intrare Programul citește de la tastatură numerele n și p. Date de ieşire Programul afișează pe ecran, în ordine crescătoare, puterile lui n mai mici sau egale cu p, separate prin câte un spațiu. Restricţii şi precizări 2 ≤ n ≤ 10 1 ≤ p < 1.000.000.000
Computers and Technology
1 answer:
rjkz [21]3 years ago
8 0

Given an array of integers (both odd and even), sort them in such a way that the first part of the array contains odd numbers sorted in descending order, rest portion contains even numbers sorted in ascending order.

Explanation:

  • Partition the input array such that all odd elements are moved to left and all even elements on right. This step takes O(n).
  • Once the array is partitioned, sort left and right parts individually. This step takes O(n Log n).

#include <bits/stdc++.h>  

using namespace std;  

void twoWaySort(int arr[], int n)  

{

   int l = 0, r = n - 1;  

   int k = 0;  

   while (l < r) {  

       while (arr[l] % 2 != 0) {  

           l++;  

           k++;  

       }

       while (arr[r] % 2 == 0 && l < r)  

           r--;  

       if (l < r)  

           swap(arr[l], arr[r]);  

   }  

   sort(arr, arr + k, greater<int>());  

   sort(arr + k, arr + n);  

}

int main()  

{  

   int arr[] = { 1, 3, 2, 7, 5, 4 };  

   int n = sizeof(arr) / sizeof(int);  

   twoWaySort(arr, n);  

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

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

   return 0;  

}

You might be interested in
You asked your colleague to provide feedback on a blog post you recently wrote. When they sent you their feedback, they made edi
Soloha48 [4]

Explanation:

This question can have both answers that is yes as well as no.

1.Yes, it can serve as an editor who completes your content and ensures it will read well to others.

2. No, the editor should have tracked changes which would have shown you where they would apply recommended edits.

7 0
3 years ago
A construction-based client would like to develop an application that can analyze an image of machinery and overlay information
Elden [556K]

A form of Extended Reality which can best assist the client with information on the repair is: 3. Augmented Reality.

<h3>What is Extended Reality?</h3>

Extended reality refers to an umbrella terminology that is used to describe all real and virtual physical environments (realities) and human-machine interactions through the use of computer technologies and wearables.

<h3>The forms of Extended Reality.</h3>

In Computer technology, there are four (4) main types of Extended Reality and these include:

  • Mixed Reality
  • Haptic Reality
  • Virtual Reality
  • Augmented Reality

Augmented Reality is mainly applied in maintenance and repair by analyzing an image of machineries and provide information that will assist in the repair process.

Read more on Augmented Reality here: brainly.com/question/9054673

4 0
2 years ago
#include #include int main( ) { int value = 10; int pid; value += 5; pid = fork( ); if (pid &gt; 0 ) { value += 20; } printf(val
ss7ja [257]

Explanation:

To understand how this program is working let us print the variable value at different stages of the program so that we can understand how it is working.

Intitally, value=10 when it was declared.

Then we added 5 and it become value=15

then we used fork() function which creates a parent(orignal) and child(duplicate)

When fork() succeeds it returns the child pid to parent and returns 0 to the child. As you can see (pid > 0) condition is always true therefore the parent pid value becomes 35 ( 15+20) and the child pid value becomes 0.

#include <stdio.h>

#include <unistd.h>

int main( ) {

   int value = 10;

     printf("%d\n",value);

   int pid;

   value += 5;

     printf("%d\n",value);

   pid = fork( );

     printf("%d\n",pid);

   if (pid > 0 )

   {

       value += 20;

   }

   printf("%d\n",value);

   return 0;

}

Output:

10 (initial value)

15 (modified value)

5343 (pid when fork is used)

35 (final modified value)

0 (child value)

15 (the parent value when fork was used)

8 0
3 years ago
Which very high-speed fiber network was already in place and being used for wide area networking (wan) transmissions, before the
Stolb23 [73]

The high-speed fiber network that is already in place and being used for wide area networking (wan) transmissions, before the IEEE developed the 10gbe ethernet standards is called SONET.

<h3>What does SONET stand for in networking?</h3>

SONET  is known to be a term that is called Synchronous Optical Network.

This is said to be defined as a standard  that is known to be used in linking or in the act of connecting fiber-optic transmission systems and it is one that is sold in North America only.

Therefore, The high-speed fiber network that is already in place and being used for wide area networking (wan) transmissions, before the IEEE developed the 10gbe ethernet standards is called SONET.

Learn more about fiber network from

brainly.com/question/26259562
#SPJ1

8 0
1 year ago
One last question
BlackZzzverrR [31]

Answer:

I love Chipotle!

Explanation:

I don't know, maybe because the food there is really good.

8 0
3 years ago
Read 2 more answers
Other questions:
  • Can your computer become infected with a virus via email
    10·1 answer
  • Write a class called Counter that represents a simple tally counter, which might be used to count people as they enter a room. T
    9·1 answer
  • True or false.the color attribute cannot recognized the hexadecimal code.
    7·2 answers
  • 1. Why do you think coding languages generally include the ability to create comments? What would those comments be used for? In
    10·1 answer
  • The sum of the elements of an integer-valued array recursively calculated as follows: The sum of an array of size 0 is 0; Otherw
    15·1 answer
  • An address has a house number, a street, an optional apartment number, a city, a state and a postal code. Define the constructor
    5·1 answer
  • Siapa mahapatih brainly.com atau yg disebut Brainly Amerika Serikat ?​
    5·1 answer
  • What happens when a dataset includes records with missing data?
    9·1 answer
  • Demons I shall be your eternal nightmare
    13·1 answer
  • What are five types of applications you can create in Visual Basic 2017?
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!