九度OJ
文章平均质量分 50
徐孜涵
自我克制是勇气的另一种表现
展开
-
九度题目1088:剩下的树 2011年清华大学计算机研究生机试真题
#include#includeusing namespace std;int scoreNumber[10001];int main(){ int i = 0, j =0; for (i = 0; i < 10001; i++) { scoreNumber[i] = 1; } int N, M, temp1, temp2,Numb原创 2014-04-18 02:44:05 · 404 阅读 · 0 评论 -
题目1516:调整数组顺序使奇数位于偶数前面,并保证奇数和奇数,偶数和偶数之间的相对位置不变
调整数组顺序使奇数位于偶数前面其实题目很简单,如果不考虑“保证奇数和奇数,偶数和偶数之间的相对位置不变”的话,我们可以借鉴快速排序的做法,从左向右找到第一个偶数,从右向左找到第一个奇数,两者交换,之后重复,知道左下标大于等于右下标;然而快速排序是不稳定的,借鉴这种思想的方法无法保证“相对位置不变”,所以我们要想些别的办法;我们开辟一个额外的空间,将从左->右遇到的奇数,原创 2015-04-13 23:53:15 · 1016 阅读 · 0 评论 -
九度题目1042:Coincidence 2008年上海交通大学计算机研究生机试真题
题目描述: Find a longest common subsequence of two strings.输入: First and second line of each input case contain two strings of lowercase character a…z. There are no spaces before, inside or after原创 2014-04-27 21:54:09 · 625 阅读 · 0 评论 -
九度 题目1112:拦截导弹 2007年北京大学计算机研究生机试真题 动态规划
#include#includeusing namespace std;int list[26];int length[26];//不需要初始化int max(int x, int y){ return (x>=y)?x:y;}int main(){ int k,i,j; while(cin>>k) { for(i=1; i<=k;原创 2014-04-24 12:39:34 · 423 阅读 · 0 评论 -
九度题目1061:成绩排序 2000年清华大学计算机研究生机试真题
#include #includeusing namespace std;#include typedef struct special{ char name[101]; int age; int score;}Spe; Spe S[1001];bool operator <= (const Spe& A, const Spe& B){ if原创 2014-04-18 02:38:58 · 471 阅读 · 0 评论 -
九度题目1043:Day of Week 2008年上海交通大学计算机研究生机试真题
#include#include#includeusing namespace std;//0 闰年 1 非闰年int mouthtime[2][13] = { 0,31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0,31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };char month[1原创 2014-04-18 02:41:44 · 556 阅读 · 0 评论 -
九度题目1040:Prime Number 求第K个素数 2008年上海交通大学计算机研究生机试真题
[code]/************************************************************** Problem: 1040 User: hrdjmax2 Language: C++ Result: Accepted Time:130 ms Memory:1920 kb素数筛选法不可用,x*i会超原创 2014-04-18 02:30:49 · 849 阅读 · 0 评论 -
剑指offer之重建二叉树 九度1385
#include#include#includeusing namespace std;#includetypedef struct Tree{ int s; struct Tree *lchild; struct Tree *rchild;}Node;int preorder[1002];int inorder[1002];bool IsOk = tr原创 2014-04-18 02:35:00 · 345 阅读 · 0 评论 -
九度题目1019:简单计算器 2006年浙江大学计算机及软件工程研究生机试真题
// 九度27 简易计算器.cpp : 定义控制台应用程序的入口点。//#include#include#include#include#include#include#includeusingnamespace std;charinput[205];mapchar,int> cha原创 2014-04-18 02:37:25 · 628 阅读 · 0 评论 -
九度题目1113:二叉树 2007年北京大学计算机研究生机试真题
#include#include using namespace std;int GetSum(int m, int n){ if(m > n) return 0; if(m == n) return 1; int l = m<<1,r = l+1; while(l<n && r<n) { l = l << 1;//最左边原创 2014-04-18 02:42:33 · 411 阅读 · 0 评论 -
判断一个序列是不是二叉搜索树的后序遍历序列
#includeusing namespace std;#include int a[10000]; bool judgebackorder(int *a,int l){ int root=a[l-1]; int i=0; for(;i<l-1;i++) { if(a[i]>root) { brea原创 2015-04-15 13:02:59 · 299 阅读 · 0 评论