1. 题目描述本题描述了一个“机器人”的世界,初始状态如下所示:现实世界中,机器人没有自主思想,只能接受指令去完成工作。类似地,题目中定义了下面的几种指令:问题:给定一系列操作指令,计算出“机器人”在完成这些指令之后,“机器人”世界(即Block world)的状态。注意:指令操作结束是使用quit...
分类:
其他好文 时间:
2014-12-12 12:59:27
阅读次数:
301
1. 题目描述Fibonacci数列定义为:A0 = 0, A1 = 1;An= An-1+ An-2, if n >= 2.问题:输入一个n( 0 ≤n ≤ 40),计算An.2. 算法设计直接利用公式计算即可,时间复杂度O(N),由于数据规模很小,可以选择先打表,然后对每一个测试数据n,直接输出...
分类:
其他好文 时间:
2014-12-12 11:36:15
阅读次数:
169
判定一棵二叉树是不是二叉平衡树。链接:https://oj.leetcode.com/problems/balanced-binary-tree/题目描述:Given a binary tree, determine if it is height-balanced.For this problem...
分类:
其他好文 时间:
2014-12-11 18:56:57
阅读次数:
162
#include
using namespace std;
bool existthesame(int *a,int n1,int *b,int n2);
int main()
{
int a[50];
int b[50];
int i, n1, n2;
cin>>n1;
for(i=0; i>...
分类:
其他好文 时间:
2014-12-11 17:31:59
阅读次数:
137
#include "OJ.h"
#include
using namespace std;
bool isSameConstructNum(int m)//判断m是否是同构数
{
int squareM = m*m;
int initialM = m*m;
int temp = 0;
int partialNum =0;
int interNum = 1;//存储对应位数需要成的倍...
分类:
其他好文 时间:
2014-12-11 17:31:55
阅读次数:
161
/* Copyright (c) 2014, 烟台大学计算机学院
* All rights reserved.
* 文件名称:test.cpp
* 作者:陈丹妮
* 完成日期:2014年 12 月 11 日
* 版 本 号:v1.0
*
* 问题描述: 逆序输出数组
* 输入描述: 输入几个整型数
* 程序输出: 逆序输出数组
*/
#include
...
分类:
编程语言 时间:
2014-12-11 17:30:11
阅读次数:
145
#include "OJ.h"
#include
using namespace std;
/*
功能: 求n(n ≤ 65536)以内的所有阿姆斯特朗数
原型:
int CalcArmstrongNumber(int n);
输入参数:
int n: n ≤ 65536
返回值:
n以内的阿姆斯特朗数的数量。
*/
bool isArmstrongNumber(in...
分类:
其他好文 时间:
2014-12-11 15:53:56
阅读次数:
234
#include
#include
#include "oj.h"
using namespace std;
/*
功能:
给出一百分制成绩,要求输出成绩等级‘A’、‘B’、‘C’、‘D’、‘E’。
90分以上为A 80-89分为B 70-79分为C 60-69分为D 60分以下为E
输入:
整数score
输出:
无
返回:
分级结果
分数不在100范围时返回-1
*/...
分类:
其他好文 时间:
2014-12-11 15:49:20
阅读次数:
213
好久没有耍代码了,手有点生,还有点痒,and 脑子有点锈。话说这个简单的东西,耍了我一个小时。
主要是最近很少碰代码。二是对python不熟悉,刚刚接触,但是顿时很热爱这个小蟒蛇。于是打算好好蹂躏它。
题目链接:https://oj.leetcode.com/problems/intersection-of-two-linked-lists/
我的思路是这样的。
首先没有循环,所以不用判断...
分类:
编程语言 时间:
2014-12-11 12:24:01
阅读次数:
229
#include "OJ.h"
#include
using namespace std;
/*
功能:计算字符串的最小周期。
原型:
int GetMinPeriod(char *string);
输入参数:
char * string:字符串。
返回值:
int 字符串最小周期。
思路:使用i表示字符串可能的周期,从周期为1开始逐渐增大1,当i满足是字符串的...
分类:
其他好文 时间:
2014-12-10 19:54:07
阅读次数:
181