我的面试(一)
前些天去北京面试了一家公司。***公司,是搞飞信项目的。我做了笔试题,答得很差,估计和这家公司无缘了。
其中的两道编程写下来留作纪念吧。
一、利用第归算法实现如下数列:
1 1 2 3 5 8 13 ......?f(31)
namespace QT
{
/// <summary>
/// 利用第归算法实现如下数列:
/// 1 1 2 3 5 8 13 ![](https://www.cnblogs.com/Images/dot.gif)
?f(31)
/// </summary>
class Program
{
/// <summary>
/// 求复合数列的第n个数的值
/// 该函数的数学表达式为
/// f(0) = 0;
/// f(1) = 1;
/// f(n) = f(n-1) + f(n-2);
/// </summary>
/// <param name="i">n</param>
/// <returns>第n个数的值</returns>
int Fun( int i)
{
if (i == 0)
{
return 0;
}
else if (i == 1)
{
return 1;
}
else
{
return Fun(i - 1) + Fun(i - 2);
}
}
static void Main(string[] args)
{
Program P = new Program();
for (int i = 1; i < 32; i++)
{
if (i < 0)
{
Console.WriteLine("Input Error!");
}
else
{
Console.WriteLine(P.Fun(i));
}
}
Console.ReadKey();
}
}
}
namespace DeletSpace
{
/// <summary>
/// 将一组字符串的前后空格去除,并将其中的多余一个的连续空格只保留一个。
/// 例如:将“ This is the target . ”转换成
/// “This is the target .”
/// </summary>
class Program
{
/// <summary>
/// 将一组字符串的前后空格去除,并将其中的多余一个的连续空格只保留一个。
/// </summary>
/// <param name="socStr">待处理的字符串</param>
/// <returns>处理后的结果</returns>
string GetStr(string socStr)
{
string targetStr = string.Empty;
string[] StrCollection = socStr.Split(' ');
foreach (string tStr in StrCollection)
{
if (!tStr.Equals(String.Empty))
{
targetStr = String.Concat(targetStr, " ", tStr);
}
}
return targetStr.Trim();
}
static void Main(string[] args)
{
string socStr = " This is the target . ";
Program p = new Program();
Console.WriteLine(p.GetStr(socStr));
Console.ReadKey();
![](/Images/OutliningIndicators/InBlock.gif)
}
}
}
这道题没啥好说的,考的就是基本功,挺简单的。我应该是写对了,就是有些方法忘了,应该不碍事。
唉面试了几次都很郁闷,离了电脑就不会写程序。考题都很简单就是不会写。
其实也不是不会都是平时常用的,工作时花不了三秒钟就搞定。在纸上做题就惨了。
呵呵不知道这面试blog写道几我能找到工作。
。。。。。。
其中的两道编程写下来留作纪念吧。
一、利用第归算法实现如下数列:
1 1 2 3 5 8 13 ......?f(31)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](/Images/OutliningIndicators/None.gif)
这道题其实在考一个简单的第归,俺当时写的乱七八糟(汗一个)。个人认为这道题的数列应该在最前边加上0即:0 1 1 2 3 5 8 13 ......?f(31)这样比较严谨。
二、将一组字符串的前后空格去除,并将其中的多余一个的连续空格只保留一个。
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](/Images/OutliningIndicators/None.gif)
这道题没啥好说的,考的就是基本功,挺简单的。我应该是写对了,就是有些方法忘了,应该不碍事。
唉面试了几次都很郁闷,离了电脑就不会写程序。考题都很简单就是不会写。
其实也不是不会都是平时常用的,工作时花不了三秒钟就搞定。在纸上做题就惨了。
呵呵不知道这面试blog写道几我能找到工作。
。。。。。。
posted on 2007-09-08 20:03 gyhanonline 阅读(644) 评论(14) 编辑 收藏 举报