Using C++, build a sorter that can rank a sequence of numbers in a descending order. It should be able to process at least 2 types of data, for example the integer sequence and the double sequence.
CODE
#include<iostream>
using namespace std;
template<class T>
void bubble(T a[], int n)
{
int i, j;
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i] < a[j])
{
T element;
element = a[i];
a[i] = a[j];
a[j] = element;
}
}
}
}
int main()
{
int a[6]={1,2,3,4,4,3};
double b[4]={6.5, 1.7, 9.5, 166.5};
bubble(a,6);
cout<<"\nSorted Order Integers: ";
for(int i=0;i<6;i++)
cout<<a[i]<<" ";
bubble(b,4);
cout<<"\nSorted Order Doubles: ";
for(int j=0;j<4;j++)
cout<<b[j]<<" ";
}
Using C++, build a sorter that can rank a sequence of numbers in a descending order....
Project: Building the software with specific functions, namely, Calculator, and Sorter Subtask 1: Building a Calculator Implementing Addition, Subtraction, Multiplication, and Division between two numbers Processing at least two types of data, for example, integer number and double number Testing the Calculator Subtask 2: Building a Sorter Implementing a sorter that can rank a sequence of numbers in a decent order Processing at least two types of data, for example, the integer sequence and the double sequence Testing the Sorter...
C programing Write a program to sort numbers in either descending or ascending order. The program should ask the user to enter positive integer numbers one at a time(hiting the enter key after each one) The last number entered by the user should be -1, to indicate no further numbers will be entered. Store the numbers in an array, and then ask the user how to sort the numbers (either descending or ascending). Call a function void sortnumbers ( int...
Write a python program to sort numbers in descending order using insertion sort? Enter numbers: 1 2 3 4 4 3 2 1
3. Write a Java method (called sumOfSquares) that reads in a sequence of integer numbers using a Scanner object. As each integer is read, the method displays that integer. The method also accumulates the sum of the squares of the integers and displays the sum when all integers are read. The method reads integers until a negative integer is read. The negative integer should not be display or added to the sum of squares. The method will not return a...
Using Haskell to write a program: fillNum fillNum takes an integer and a list of numbers to build a list of the specified length made up by repeating the numbers from the input list as many times as required. That is, the output list has the specified length same as the length specified by the input integer. For example: fillNum 4 [5,6,7,8,9,10] should output [5,6,7,8] fillNum 9 [4,3,2,1] should output [4,3,2,1,4,3,2,1,4] fillNum 7 [1,2,3] should output [1,2,3,1,2,3,1]
Big Numbers Library The creators of C++ have created primitive data types to allow developers to store numbers of various size they expect most users will need. Such as short, int, double. In our case we want to expand on these primitive data types and allow users to store big numbers that can store up to 1,000 digits long. In order to do this, you will create a BigNumbers class, using TDD, Test Driven Development, that will use vectors from...
Write a C program that reads a sequence of numbers and display a message 1. The numbers a re red from the standard input. 2. The first number is the length of the sequence (n) followed by n numbers. 3. If n is 0 or negative, the program displays the message "Error_1" followed 4. If the length is shorter than n, it displays "Error_2" followed by a new line 5. The program inspects the list and display one of the...
Write a C program to build a complete binary tree with 7 nodes using link list implementation. Requirements: 1) Ask the user to enter randomly seven integer numbers as data value for each node 2) Build the tree using link list 3) Print the tree in inorder , preorder , and post order 4) Use functions for each print type .
3. (5 pts) Rank the following alkyl bromides in order of reactivity using numbers 1-5 (1 - most reactive: 5 least reactive) in an Sy2 reaction where the alkyl bromide is converted to the corresponding nitrile: NaCN R-Br R-CN + NaBr acetone 4. (5 pts) Rank the following alkyl bromides in order of reactivity using numbers 1-5 (1 = most reactive; 5 - least reactive) in an Syl reaction where the alkyl bromide is converted to the corresponding alcohol: R-Br...