In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the relevant knowledge of how to use the java sorting algorithm, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value. I believe you will gain something after reading this java sorting algorithm. Let's take a look at it.
Title:
Topic description:
The story of Tian Ji horse racing is known to all. Tian Ji won a horse race with the king, earning 200 in a win and losing a loss of 200. There was no impact on the draw. Ask Tian Ji how much he can earn.
Enter:
Enter data for up to 50 test cases. Each data starts with a positive integer n (1000), which is the number of horses. In the second line, each integer is the speed of Tian Ji's horse. Each integer in the third line is the speed of the king's horse. If n is 0, the input ends.
Output:
For each input, the output line contains a single number, which is the maximum amount of money Tian Ji will get.
Train of thought:
If you can use the worst horse to get the worst horse on the opposite side, use the worst horse or trade the worst horse for the other party's best horse.
Code
# include / / use sorting to facilitate processing void sort (int * a, int left, int right) {if (left > = right) {return;} int I = left; int j = right; int key = a [left]; while (I < j) {while (I < j & & key = a [I])) } a [j] = a [I];} a [I] = key; sort (a, left, I-1); sort (a, I + 1, right);} int main () {int SL = 0; int XHBL = 0; int DYFS = 0; int * DYZZ = 0; int * DEZZ = 0; int * DEJWZZ = 0; int DIYIZU [10] = {0} Int DIERZU [10] = {10}; scanf ("% d", & SL); for (XHBL = 0; XHBL < SL; XHBL++) scanf ("% d", & DIYIZU [XHBL]); for (XHBL = 0; XHBL < SL; XHBL++) scanf ("% d", & Dierzu [XHBL]); sort (DIYIZU,0, SL-1); sort (DIERZU,0, SL-1); DYZZ = & DIYIZU [0] DEZZ = & DIERZU [0]; DEJWZZ = & DIERZU [SL-1]; for (XHBL=0;XHBL= * DEZZ) / / is it a tie if the two horses are equal in speed or the King of Qi wins? Here it is counted as equality {if (* DYZZ = * DEZZ) DYFS + = 200; DYZZ++; DEZZ++;} else {DEJWZZ--; DYZZ++; DYFS-= 200;} printf ("Tianji InTotal:%d", DYFS); return 0 } this is the end of the article on "how to use the java sorting algorithm". Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how to use the java sorting algorithm". If you want to learn more knowledge, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.