Two elements of a binary search tree (BST) are swapped by mistake.
Recover the tree without changing its structure.
Note:
A solution using O(n) space is pretty straight forward. Could you devise a ...
分类:
其他好文 时间:
2015-08-01 11:34:59
阅读次数:
108
描述: 给定一段连续的整数,求出他们中所有偶数的平方和以及所有奇数的立方和。代码: #include#include#include#include#include using namespace std;int main(){ unsigned m,n,x,y,i; while (...
分类:
其他好文 时间:
2015-08-01 11:29:18
阅读次数:
116
执行select语句时不需要Conn.Open()using (SqlConnection Conn = new SqlConnection(connStr)) { //Conn.Open(); string sql ...
分类:
其他好文 时间:
2015-08-01 11:26:50
阅读次数:
86
描述: 统计给定的n个实数中,负数、零和正数的个数。代码: #include#include#include#include#include using namespace std;#define N 200int main(){ int n,neg,pos,zero; double...
分类:
其他好文 时间:
2015-08-01 11:23:00
阅读次数:
88
字符串子序列查找问题,设置两个指针,一个指向子序列,另一个指向待查找的序列,查找个字符串一次即可判断。 1 #include 2 #include 3 using namespace std; 4 char s[100002]; 5 char t[100002]; 6 int main() { .....
分类:
其他好文 时间:
2015-08-01 11:15:02
阅读次数:
114
题目Implement the following operations of a queue using stacks.push(x) – Push element x to the back of queue.
pop() – Removes the element from in front of queue.
peek() – Get the front element.
empty(...
分类:
其他好文 时间:
2015-08-01 10:08:20
阅读次数:
120
#include
using namespace std;
const int maxn = 1000000 + 10;
int T,n,m,k,Case = 0,a[maxn],cnt[maxn];
map p;
vector g[105];
int main() {
scanf("%d",&T);
while(T--) {
scanf("%d%d%d",&n,&...
分类:
其他好文 时间:
2015-08-01 10:07:38
阅读次数:
118
题意:给出一个三角形的三点,然后取三边的三等分点和相对的顶点连线,问围起来的三角形的面积。
题解:把CF、AD、BE三个向量先求出来,然后两两取交点,最后用叉积求面积,最后要四舍五入。#include
#include
#include
#include
using namespace std;
const double...
分类:
其他好文 时间:
2015-08-01 10:04:58
阅读次数:
157
很容易想到是最大匹配:行和列看做点,每一个可放置的位置看做边,先求一遍最大匹配,然后枚举删除每一条边,如果删除了某一条边发现求出来的最大匹配比之前少,则这条边对应的格点是”重要点“。 1 #include 2 #include 3 #include 4 using namespace std;...
分类:
其他好文 时间:
2015-08-01 10:00:08
阅读次数:
81
题意:Susake要完成n个任务,一共有v天,每种任务有起始时间和终止时间,价值为w[i],求最大价值输入110 51 5 1003 10 105 10 1001 4 26 12 266输出102#include #include #include using namespace std;struc...
分类:
其他好文 时间:
2015-08-01 06:22:46
阅读次数:
95