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
When you gather primary or secondary data, what part of the market information management process are you participating in?
Umnica [9.8K]

Answer:

Heyyyooo!

The answer is market research.

Hope this helps!

Explanation:

Market research is the way toward gathering, analyzing and interpreting data about a market, about an item or administration to be offered available to be purchased in that advertise, and about the past, present and potential clients for the item or administration; examination into the attributes, ways of managing money, area and necessities of your business' objective market, the industry all in all, and the specific contenders you confront.  

3 0
3 years ago
TWO QUICK QUESTIONS
andrezito [222]
I'm guessing 8? But I'm not 100% positive 
5 0
3 years ago
Please help What two Boolean operators can you use to narrow your search results?
daser333 [38]

Answer:

if and and not and or ans all

7 0
3 years ago
In which of the following is “y” not equal to 5 after execution? X is equal to 4.
Step2247 [10]

Answer:

d) y=x++

Explanation:

In all 3 statements:

y= ++x;

y=x=5;

y=5;

The value of y is equal to 5.

However in the statement y=x++, the value of 5 is equal to value of x prior to the increment operation. The original value of x was 4. So the value of y will be 4. Note that after the statement execution, the value of x will be updated to 5. In effect y=x++ can be visualized as a sequence of following steps:

x=4;

y=x;

x=x+1;

5 0
3 years ago
Will give brainliest and good amount of points, no false answers.
nlexa [21]

The problem with the swap function is that it loses the value at the first index, as soon as it gets overwritten by the value at the second index. This happens in the first statement. To fix it, you need a helper variable.

First you're going to "park" the index at the first index in that helper variable, then you can safely overwrite it with the value at the second index. Then finally you can write the parked value to the second index:

var swap = function(array, firstIndex, secondIndex) {

let helper = array[firstIndex];

array[firstIndex]  = array[secondIndex];

array[secondIndex] = helper;

};

I hope this makes sense to you.

7 0
3 years ago
Other questions:
  • Suppose that a company offers quantity discounts. If up to​ 1,000 units are​ purchased, the unit price is ​$1010​; if more than​
    7·1 answer
  • Assume that the variables v, w, x, y, and z are stored in memory locations 200, 201, 202, 203, and 204, respectively.
    6·1 answer
  • Why is yo utu be down?<br> (You restrict talking about yo utu be, really)
    11·2 answers
  • How can injection attacks be prevented? Check all that apply
    6·2 answers
  • Sites like Zillow get input about house prices from a database and provide nice summaries for readers. Write a program with two
    12·1 answer
  • Can an SQL function return multiple values? No answer needed, take the points.
    12·1 answer
  • Add me on Fortnite. Epic is smashman892. *Ik it sux but it's an old account* Comment ur epic
    6·2 answers
  • Zybook C++ 3.21 answer
    9·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    11·1 answer
  • Jeroo Bob has just awoken from a long night's sleep and is hungry for some winsum flowers. He walks out of
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!