文件名称:change
介绍说明--下载内容来自于网络,使用问题请自行百度
队列程序:n个士兵的编号分别为1,2,3,…,n,每次站队时长官都是要求n个士兵从排头到排尾依次是编号为1,2,3…,n的士兵。如果次序乱了,长官很不高兴,后果会很严重。
有一次士兵按编号次序刚刚站好队,突然长官下令让所有士兵立刻回宿舍拿水壶,要去执行一个临时任务,由于时间紧张,慌乱的士兵们拿到水壶回来后,有的没能站到自己应该站的位置。
长官不高兴了,于是下令让士兵们通过两两交换位置的方法按原来次序站好,并且规定:每一次交换位置,只能是排头的人和除排头外的任一个位置的人交换。现在告诉你士兵们的队形,问最少交换多少次能恢复到1,2,3,。。。,n的顺序。-Queue program: n soldiers were numbered 1,2,3, ..., n, each time stand n soldiers Executive is required from the head to the tail followed by numbered rows 1,2,3 ..., n soldiers . If you order in chaos, sir very unhappy consequences will be very serious. Once the order by number of soldiers just stand a good team, suddenly Executive ordered that all the soldiers immediately take the kettle back to the dorm, going to perform a temporary task, due to the time constraints, panic soldiers came back to get the kettle, and some could not stand to they should stop position. Executive unhappy, then ordered the soldiers to swap positions through twenty-two method according to the original order stand, and states: every exchange position, only the first row of the first row and the addition of either a foreign exchange position of the person. Now tell your soldiers in formation, and asked how many times the minimum exchange can be restored to 1,2,3,. . . , N for the order.
有一次士兵按编号次序刚刚站好队,突然长官下令让所有士兵立刻回宿舍拿水壶,要去执行一个临时任务,由于时间紧张,慌乱的士兵们拿到水壶回来后,有的没能站到自己应该站的位置。
长官不高兴了,于是下令让士兵们通过两两交换位置的方法按原来次序站好,并且规定:每一次交换位置,只能是排头的人和除排头外的任一个位置的人交换。现在告诉你士兵们的队形,问最少交换多少次能恢复到1,2,3,。。。,n的顺序。-Queue program: n soldiers were numbered 1,2,3, ..., n, each time stand n soldiers Executive is required from the head to the tail followed by numbered rows 1,2,3 ..., n soldiers . If you order in chaos, sir very unhappy consequences will be very serious. Once the order by number of soldiers just stand a good team, suddenly Executive ordered that all the soldiers immediately take the kettle back to the dorm, going to perform a temporary task, due to the time constraints, panic soldiers came back to get the kettle, and some could not stand to they should stop position. Executive unhappy, then ordered the soldiers to swap positions through twenty-two method according to the original order stand, and states: every exchange position, only the first row of the first row and the addition of either a foreign exchange position of the person. Now tell your soldiers in formation, and asked how many times the minimum exchange can be restored to 1,2,3,. . . , N for the order.
(系统自动生成,下载前可以参看下载内容)
下载文件列表
change/
change/change.c
change/change.docx
change/change.c
change/change.docx
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.