| |

VerySource

 Forgot password?
 Register
Search
Author: 丁欠欠

How to solve sorting problems in C ++? ? ? ?

[Copy link]

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-7-28 15:30:01
| Show all posts
Wow, I didn't expect that there are so many methods for such a simple topic. FK U!
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-2 08:45:01
| Show all posts
#include <algorithm>
#include <functional>

int Array[]={5,6,3,8,3,9,7,2,1,4,0};
const size_t S=sizeof(Array)/sizeof(Array[0]);

std::sort(Array,Array+S,std::greater<int>());
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-21 06:00:01
| Show all posts
#include "iostream.h"
void main()
{
        int a[10]={5,6,8,3,9,7,2,1,4,0},i,j,you;
             for(i=0;i<10;i++)
              for(j=0;j<9;j++)
                  if(a[j]>a[j+1])
                  {
                        you=a[j];
                        a[j]=a[j+1];
                        a[j+1]=you;
                  }
              for(i=0;i<10;i++)
                 cout<<a[i]<<" ";


}
Reply

Use magic Report

0

Threads

1

Posts

1.00

Credits

Newbie

Rank: 1

Credits
1.00

 China

Post time: 2020-9-3 16:11:29
| Show all posts
Bubbling method
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list