Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  lab4.2
Language: C/C++
Code:
#include <iostream>
#include <cstring>

using namespace std;

int main()
{
    char str[100];
    int codei, codej,temp;
    printf("Input String: ");
                std::cin >> str;
               

    int size=strlen(str);//размер массива
    
     for(int i=0;i<size; i++)
     {
           codei=str[i];  
         for(int j=i+1; j<size; j++)
         {
             codej=str[j];
            if (codei>codej)
            {
            temp=str[i];
            str[i]=str[j];
            str[j]=temp;
            }
         } //j
     } //i
     std::cout << str << std::endl;
}     
Comments: