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
Naddika [18.5K]
3 years ago
7

Write a function that will alphabetize a string WITHOUT using the sort function :

Computers and Technology
1 answer:
Dimas [21]3 years ago
7 0

Answer:

here is code in C++.

#include <bits/stdc++.h>

using namespace std;

// function to alphabetize the input string

void alphabetize(string &str)

{

// find the length of string

 int n=str.size();

 

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

      for(int y=x+1;y<n;y++)

      {  

          //swap the character

          if(str[x]>str[y]){

              char ch=str[x];

              str[x]=str[y];

              str[y]=ch;

          }

      }

  }

 

  cout<<"alphabetize string is: "<<str<<endl;;

 

}

int main()

{// string variable to read input

  string inp;

 

  cout<<"Please Enter a String in lowercase :";

  //reading the input

  cin>>inp;

  // call function with inp argument

  alphabetize(inp);

  return 0;

  }

Explanation:

Declare a variable "inp" of string type and assign the input string to it. call the alphabetize() function with argument "inp".In the alphabetize(),find the length  of input string.Then travers the string and if a character is greater than any  next character in the string then swap it, so that all the character are sorted.

Output:

Please Enter a String in lowercase :helloworld                                                                                                                

alphabetize string is: dehllloorw

You might be interested in
int foo(int A[], int left, int right){ int i, x, q, N; if(right &lt;= left) return 1; x = 0; for(i=left; i &lt;= right; i++) x +
sineoko [7]

Answer:

quicksort.cpp

void quickSort(int arr[], int left, int right) {

     int i = left, j = right;

     int tmp;

     int pivot = arr[(left + right) / 2];

 

     /* partition */

     while (i <= j) {

           while (arr[i] < pivot)

                 i++;

           while (arr[j] > pivot)

                 j--;

           if (i <= j) {

                 tmp = arr[i];

                 arr[i] = arr[j];

                 arr[j] = tmp;

                 i++;

                 j--;

           }

     };

 

     /* recursion */

     if (left < j)

           quickSort(arr, left, j);

     if (i < right)

           quickSort(arr, i, right);

}

3 0
3 years ago
Software refers to:
aev [14]

Answer:

Software refers to the programs that run on your computer.

Explanation:

Examples are Word and PowerPoint. Computer programs contain instructions that the hardware carries out. ... Another program (called a compiler or interpreter) translates these instructions into machine language which the computer hardware understands.

7 0
3 years ago
Read 2 more answers
Use the drop-down menus to complete statements about safe and blocked senders lists.
Ierofanga [76]

Answer:

it already has an answer and it's right so i don't see the point to needing to answer this

6 0
3 years ago
Which is a correct statement about having access to technology in a study environment?
Debora [2.8K]
The answer is the 3rd option : Using a computer to research information can be helpful.

Hope this helps!! :)

5 0
3 years ago
Read 2 more answers
Anyone want to talk?
Fed [463]

Answer:

hey

Explanation:

3 0
3 years ago
Read 2 more answers
Other questions:
  • are designed to locate information based on the nature and meaning of Web content, not simple keyword matches Select one: a. Cra
    14·1 answer
  • How many 16ths are in 3/8 of an inch
    12·1 answer
  • Each row in a database is a set of unique information called a(n) (A.)table,(B.)record,(C.)object,(D.)field
    12·2 answers
  • Nathan wants to create multiple worksheet containing common formatting styles for his team members. Which file extension helps h
    9·1 answer
  • Howie is a business analyst who is given access to the database of a product prior to its launch. He needs to understand the dat
    9·1 answer
  • A previously saved labels report can be accessed from the
    9·1 answer
  • Are the buying and selling of stocks centralized activities? Why or why not?
    10·2 answers
  • What is the term used to describe a computer system that can store literary documents, link them according to logical relationsh
    5·1 answer
  • Select each task that may be completed using a word processor.
    8·2 answers
  • Mention any
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!