笔试题
junius2020
这个作者很懒,什么都没留下…
展开
-
字符串循环移位
// strMove1.cpp : Defines the entry point for the console application.////时间复杂度O(L),空间复杂度O(1)#include "stdafx.h"#include <stdio.h>#include <string.h>#include <iostream>void moveOneStep(char a[])转载 2015-08-09 10:53:39 · 362 阅读 · 0 评论 -
矩阵相乘 一维数组表示
// matrixMulti.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include <stdio.h>#include <iostream>#define N 4#define Len 16void multi(int a[],int b[]){ int i,j,原创 2015-08-09 10:41:53 · 1322 阅读 · 0 评论 -
回文数 找最长回文子串
/* Catcher是MCA国的情报员,他工作时发现敌国会用一些对称的密码进行通信,比如像这些ABBA,ABA,A,123321,但是他们有时会在开始或结束时加入一些无关的字符以防止别国破解。比如进行下列变化 ABBA->12ABBA,ABA->ABAKK,123321->51233214 。因为截获的串太长了,而且存在多种可能的情况(abaaab可看作是aba,或baaab的加密形式),Cath转载 2015-08-09 10:47:40 · 525 阅读 · 0 评论 -
回文数 找第n个回文数
package HW;public class NthHuiWenNum { //数位指个位,十位,百位,千位。。。 public static void main(String[] args) { int input = 1201; //Integer.parseInt(args[0]); long res = find(in转载 2015-08-09 10:48:23 · 1277 阅读 · 0 评论 -
约瑟夫环 循环报数 华为oj
描述: 输入1个数字和多个字符,中间均以空格隔开。假设数字取值为m(范围1~9),后面字符个数为n。假设n个字符围成一圈,从第一个字母开始循环报数,当数到m以后,第m个字母就出列,直到这n个字母全部出列。最后,按照出列的顺序输出这些字母,中间仍以空格隔开。取值范围:m为1到9, 字符个数n大于1小于20。 运行时间限制: 无限制 内存限制: 无限制 输入: 第一个为数字,后面为多个原创 2015-08-09 11:14:38 · 849 阅读 · 0 评论 -
判断数字中是否包含两个相同的子串 华为oj
描述: 判断给定的一个数字,把它当成字符串以后,该字符串中是否包含相同的两个子串,子串的长度要求大于等于2。 比如:12123,该数字包含两个“12”子串; 又比如:1223122,该数字包含两个“122”子串。运行时间限制: 无限制 内存限制: 无限制 输入: 待判断的正整型数字,最大长度为9。 输出: 0:不包含; 1:包含。样例输入: 12123 样原创 2015-08-09 11:01:02 · 489 阅读 · 0 评论 -
360oj 输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离。
Problem Description 输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离。 Input 输入数据有多组,每组占一行,由4个实数组成,分别表示x1,y1,x2,y2,数据之间用空格隔开。 Output 对于每组输入数据,输出一行,结果保留两位小数。 Sample Input 0 0 0 1 0 1 1 0 Sample Output 1.00 1原创 2015-08-10 22:56:23 · 7664 阅读 · 1 评论 -
360oj 字符串统计
Problem Description 对于给定的一个字符串,统计其中数字字符出现的次数。 Input 输入数据有多行,第一行是一个整数n,表示测试实例的个数,后面跟着n行,每行包括一个由字母和数字组成的字符串。 Output 对于每个测试实例,输出该串中数值的个数,每个输出占一行。 Sample Input 2 asdfasdf123123asdfasdf asdf1111111原创 2015-08-10 22:57:51 · 448 阅读 · 0 评论 -
猴子分桃 笔试题
海滩上有一堆桃子,五只猴子来分。 第一只猴子把这堆桃子凭据分为五份,多了一个,这只猴子把多的一个扔入海中,拿走了一份。 第二只猴子把剩下的桃子又平均分成五份,又多了一个,它同样把多的一个扔入海中,拿走了一份, 第三、第四、第五只猴子都是这样做的,问海滩上原来最少有多少个桃子? 方法一:递归#include <stdio.h>#define N 4int divide(int n,int m)原创 2015-08-18 00:05:39 · 625 阅读 · 0 评论 -
大数相乘
// bigNumAdd.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include <stdio.h>#include <string.h>#define MAX 101int bigNumMulti(char a[],char b[],char result[]);voi原创 2015-08-09 10:40:39 · 272 阅读 · 0 评论 -
大数相加
// bigNumAdd.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include <stdio.h>#include <string.h>#define MAX 101int bigNumAdd(char a[],char b[],char sum[]);void pri原创 2015-08-09 10:39:38 · 339 阅读 · 0 评论 -
约瑟夫环 不同密码
// Joseph2.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include "stdio.h"#include <iostream>#include <malloc.h>using namespace std;struct node{ int num;//结点编转载 2015-08-09 10:38:33 · 2502 阅读 · 1 评论 -
空格替换2
class Replacement {public: string replaceSpace(string iniString, int length) { // write code here if (length == 0) return iniString; int lenOfspace = 0;转载 2015-08-09 10:56:51 · 374 阅读 · 0 评论 -
最小长方形 华为oj
描述: 给定一系列2维平面点的坐标(x, y),其中x和y均为整数,要求用一个最小的长方形框将所有点框在内。长方形框的边分别平行于x和y坐标轴,点落在边上也算是被框在内。 运行时间限制: 10 Sec 内存限制: 128 MByte 输入: 测试输入包含若干测试用例,每个测试用例由一系列坐标组成,每对坐标(x y) 占一行,其中|x|和|y|小于 1000;一对(0,0) 坐标标志原创 2015-08-09 11:16:38 · 401 阅读 · 0 评论 -
大数相加 华为oj 超长正整数相加
// ojTest05.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include <stdio.h>#include <string.h>#define MAX 101#define MAX2 202void AddLongInteger(char * pcAddend, c原创 2015-08-09 11:07:54 · 1596 阅读 · 0 评论 -
空格替换
请编写一个方法,将字符串中的空格全部替换为“%20”。假定该字符串有足够的空间存放新增的字符,并且知道字符串的真实长度(小于等于1000),同时保证字符串由大小写的英文字母组成。 给定一个string iniString 为原始的串,以及串的长度 int len, 返回替换后的string。 测试样例: “Mr John Smith”,13 返回:”Mr%20John%20Smith” ”原创 2015-08-09 10:56:07 · 527 阅读 · 0 评论 -
基本字符串压缩
利用字符重复出现的次数,编写一个方法,实现基本的字符串压缩功能。比如,字符串“aabcccccaaa”经压缩会变成“a2b1c5a3”。若压缩后的字符串没有变短,则返回原先的字符串。 给定一个string iniString为待压缩的串(长度小于等于3000),保证串内字符均由大小写英文字母组成,返回一个string,为所求的压缩后或未变化的串。 测试样例 “aabcccccaaa” 返回:原创 2015-08-09 10:57:53 · 343 阅读 · 0 评论 -
取石子 斐波那契博弈 华为oj
// ojTest03.cpp : Defines the entry point for the console application.//#include "stdafx.h"//华为2014校招机试题第三题,160分 #include<stdio.h> #define N 47 int main() { int f[N]; f[0] = 0, f[1] =转载 2015-08-09 11:04:57 · 352 阅读 · 0 评论 -
循环链表实现约瑟夫环
// joseph3.cpp : Defines the entry point for the console application.//循环链表实现约瑟夫环#include "stdafx.h"#include <stdio.h>#include <malloc.h>typedef struct Lnode{ int data; struct Lnode *next;原创 2015-08-09 10:25:59 · 357 阅读 · 0 评论 -
约瑟夫环输出最后一个数字
//#include "stdafx.h"#include <stdio.h>#include <string.h>#include <iostream>using namespace std;#define NUM 100//总人数#define N转载 2015-08-09 10:29:22 · 925 阅读 · 0 评论 -
删除字符串中多余的空格 美团校园招聘模拟测试题
// meituanTest01.cpp : Defines the entry point for the console application.////删除字符串中多余空格//接收" i am i "//返回"i am i"#include "stdafx.h"#include <stdio.h>#include <string.h>char* formatStri原创 2015-09-07 13:03:52 · 372 阅读 · 0 评论