算法
山顶处见
好的关系往往是势均力敌
展开
-
全排序算法(选择,冒泡,快速,插入)
详解全在代码里:#include<bits/stdc++.h>using namespace std;int a[10005];int n;/*在一个长度为N的无序数组中,第一趟遍历N个数据,找出其中最小的数值与第一个元素交换;第二趟遍历剩下的N-1个数据,找出其中最小的数值与第二个元素交换……第N-1趟遍历剩下的2个数据,找出其中最小的数值与第N-1个元素交换,至此选择排序完成。*/void choicesort(int a[],int n)//选择排序{ for原创 2020-12-10 16:15:39 · 197 阅读 · 0 评论 -
Soilers(士兵站队问题)
N soldiers of the land Gridland are randomly scattered around the country.A position in Gridland is given by a pair (x,y) of integer coordinates. Soldiers can move - in one move, one soldier can go one unit up, down, left or right (hence, he can change ei原创 2020-11-29 14:49:29 · 458 阅读 · 0 评论 -
计算字符串变成回文串的最小交换次数
A palindrome is a string of symbols that is equal to itself when reversed. Given an input string, not necessarily a palindrome, compute the number of swaps necessary to transform the string into a palindrome. By swap we mean reversing the order of two adja原创 2020-11-25 15:11:51 · 1101 阅读 · 0 评论 -
最大连续子序列
给定K个整数的序列{ N1, N2, …, NK },其任意连续子序列可表示为{ Ni, Ni+1, …,Nj },其中 1 <= i <= j <= K。最大连续子序列是所有连续子序列中元素和最大的一个,例如给定序列{ -2, 11, -4, 13, -5, -2 },其最大连续子序列为{ 11, -4, 13 },最大和为20。在今年的数据结构考卷中,要求编写程序得到最大和,现在增加一个要求,即还需要输出该子序列的第一个和最后一个元素。Input测试输入包含若干测试用例,原创 2020-11-29 14:24:03 · 1313 阅读 · 0 评论 -
迷宫
标题:迷宫X星球的一处迷宫游乐场建在某个小山坡上。它是由10x10相互连通的小房间组成的。房间的地板上写着一个很大的字母。我们假设玩家是面朝上坡的方向站立,则:L表示走到左边的房间,R表示走到右边的房间,U表示走到上坡方向的房间,D表示走到下坡方向的房间。X星球的居民有点懒,不愿意费力思考。他们更喜欢玩运气类的游戏。这个游戏也是如此!开始的时候,直升机把100名玩家放入一个个小房间内。玩家一定要按照地上的字母移动。迷宫地图如下:UDDLUULRULUURLLLRRRURRU.原创 2020-10-21 20:02:55 · 24434 阅读 · 0 评论