Computer Science, asked by sheshagirisindhu, 1 month ago

An oil factory has N number of containers and
each has a different capacity. During
renovation, the manager decided to make
some changes with the containers. He wishes
to make different pairs for the containers in
such a way that in the first pair the container
of maximum capacity is paired with the
container of minimum capacity, and so on for
the rest of the containers, to maintain a
balance throughout all the pairs of containers.
Write an algorithm to make different pairs of
containers in such a way that the first
container in the pair is of maximum capacity
and second container in the pair is of minimum
capacity. write the c program

Answers

Answered by satyabalajich
17

#include <stdio.h>

void main {

int N;

int max ;

int min ;

int a[] ;

for (int i = 0 ; i <= N ; i++){

a[i] = max ;

a[i+1]= min ;

}

printf (a) ;

}

Answered by kumarniranjan0202200
0

Answer:

#include<iostream>

#include<bits/stdc++.h>

using namespace std;

int main(){

  int n;

  cin>>n;

  int arr[n];

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

     cin>>arr[i];

  }

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

     for(int j = i; j<n-1; j++){

        if(arr[j] < arr[j+1])

        {

         int temp = arr[j];

         arr[j] = arr[j+1];

         arr[j+1] = temp;

        }

     }

 }

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

     if(i != n-1){

        cout<<arr[i]<<" "<<arr[n-1]<<endl;

        n = n-1;

     }

     else{

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

        }

  }

  return 0;

}

Explanation:

Similar questions