
编程题
再见范特西
这个作者很懒,什么都没留下…
展开
-
2016校招编程题<二>
某人有一张圆桌,其中心为(x,y),现在要把桌子中心移到(x1,y1),每次移动一步,都得在圆桌边界固定一个点,然后将桌子围绕这个点旋转,问至少几步可以完成移动?输入:5个整数r,x,y,x1,y1其中1<=r<=100000,-100000<=x,y,x1,y1<=100000 输入样例:2 0 0 04输出样例:1#include #include原创 2015-09-27 15:22:40 · 541 阅读 · 0 评论 -
2016校招编程题<三>
给定一个字符串.问是否可以通过添加一个字符将其变成回文串。输入:一行由小写字母构成的字符串,长度不超过10。输出:YES 或者NO输入样例:testest输出样例:YES#include #include using namespace std;bool fun(string str){ if (str.length() == 0)原创 2015-09-27 15:24:33 · 611 阅读 · 1 评论 -
2016校招编程题<四>
编写函数Sum(n) = 1+2+3+4+5+6+·····+n;int Sum(int n) { int sum = 0; if(n <= 0) return sum; for(int i = 1; i < = n; i++) { sum = sum + i; } if(sum < 0) { cout << “error” << end原创 2015-09-27 15:27:56 · 554 阅读 · 0 评论 -
2016校招编程题<一>
一个长度为N的数组中包含正数,负数和0,请实现一个函数找出最长和为零的连续子数组。输入:所有数组元素在一行,空格隔开输出:所有数组元素在一行,空格隔开输入样例:1 2 3 4 -1 -2 -4 -3 1 2输出样例:1 2 3 4 -1 -2 -4 -3 #include #include #include using namespace std;原创 2015-09-27 15:19:10 · 535 阅读 · 0 评论