| |

VerySource

 Forgot password?
 Register
Search
View: 3367|Reply: 23

C ++ masters help, give an answer

[Copy link]

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-3-13 16:30:01
| Show all posts |Read mode
Design a program that inputs 10 integers into an array and adjusts the position of the 10 numbers in the array so that the largest one becomes the first element of the array and the smallest one becomes the last element of the array.
Reply

Use magic Report

0

Threads

126

Posts

73.00

Credits

Newbie

Rank: 1

Credits
73.00

 Hong Kong

Post time: 2020-6-9 12:00:01
| Show all posts
Should the data in the array be sorted?

Is it just the largest and smallest 2 numbers?
Reply

Use magic Report

0

Threads

55

Posts

44.00

Credits

Newbie

Rank: 1

Credits
44.00

 Invalid IP Address

Post time: 2020-6-9 15:45:01
| Show all posts
Help with this one? Traverse the array, record the position of the maximum and minimum values, and then exchange with the head and tail.
Reply

Use magic Report

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-6-9 19:45:01
| Show all posts
Just sort them in descending order.
Reply

Use magic Report

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-6-10 03:15:01
| Show all posts
Brother, I am a newbie~~~~
How to write in descending order?
And how about writing only the swap of the largest number and the position of the array head and the smallest number and the position of the array end? First, thank you.
Reply

Use magic Report

0

Threads

37

Posts

28.00

Credits

Newbie

Rank: 1

Credits
28.00

 China

Post time: 2020-6-10 09:15:01
| Show all posts
The most basic sort
Define two variables to mark the coordinates of the largest and smallest elements, then traverse the array, and then swap.
Reply

Use magic Report

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-6-10 16:15:01
| Show all posts
Can you write it for me?
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-6-10 20:00:02
| Show all posts
Go get a bubble on the Internet and you're done
Reply

Use magic Report

0

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 Unknown

Post time: 2020-6-10 21:30:01
| Show all posts
const int len=n;
int *array=new int[len];
input array[]
Above

for(int i=0;i<len-1;i++)
{
  for(int j=i+1;j<len;j++)
  {
    if(array[i]<array[j])
    {
       int tmpInt=array[i];
       array[i]=array[j];
       array[j]=tmpInt;
    }

  }

}
Reply

Use magic Report

0

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-6-11 03:00:01
| Show all posts
Explain, this is sorting, is that your sort? Or only deal with the maximum and minimum?
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