面试总结系列一

笔试题

1.0,1,2,...,1000 中出现几个0 C# 和 js 作答
/// <summary>
/// 1.0,1,2,...,1000 中出现193个0
/// </summary>
public void subject1()
{
int originPoint = 0;
int targetPoint = 1000;
int count = 0;
for (int tempNo = originPoint; tempNo <= targetPoint; tempNo++)
{
if (tempNo.ToString().Contains("0"))
{
count++;
}
if (tempNo.ToString().Contains("00"))
{
count++;
}
if (tempNo.ToString().Contains("000"))
{
count++;
}
}
System.Web.HttpContext.Current.Response.AddHeader("Content-Type", "text/html");
System.Web.HttpContext.Current.Response.CacheControl = "no-cache";
System.Web.HttpContext.Current.Response.Write(JsonConvert.SerializeObject(count));
}
2.5712.18 转成 五千七百一十二元一角八分 ajax回调
/// <summary>
/// 5712.18 转成 五千七百一十二元一角八分
/// </summary>
public void subject2(string money)
{
double MyNumber = Convert.ToDouble(money);
String[] MyScale = { "分", "角", "元", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿", "拾", "佰", "仟", "兆", "拾", "佰", "仟" };
String[] MyBase = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" };
String M = "";
bool isPoint = false;
if (money.IndexOf(".") != -1)
{
money = money.Remove(money.IndexOf("."), 1);
isPoint = true;
}
for (int i = money.Length; i > 0; i--)
{
int MyData = Convert.ToInt16(money[money.Length - i].ToString());
M += MyBase[MyData];
if (isPoint == true)
{
M += MyScale[i - 1];
}
else
{
M += MyScale[i + 1];
}
}
System.Web.HttpContext.Current.Response.AddHeader("Content-Type", "text/html");
System.Web.HttpContext.Current.Response.CacheControl = "no-cache";
System.Web.HttpContext.Current.Response.Write(JsonConvert.SerializeObject(M));
}
3.
testtable1
id deptment
1 市场
2 采购
3 售后

testtable2
id deptid name
1 1 赵一
2 1 钱二
3 2 孙三
4 3 李四
5 4 王五


得出
id deptment name
1 市场 赵一
2 市场 钱二
3 采购 孙三
4 售后 李四
5 黑人 王五

SELECT a.id,a.name,ISNULL(b.deptment, '黑人') FROM testtable2 a
left JOIN testtable1 b on a.deptid=b.id;

注意:别瞎用聚合函数groupby

面试题:

1.cookie和session运行机制

2.http协议

3.面向对象开发思想

4.代码规范化

5.double和Double区别
用于泛型传参的时候,只能传Double不能传double


6.Http协议涉及到的类有哪些

posted on 2016-02-29 14:43  weikang  阅读(145)  评论(0编辑  收藏  举报

导航