自己总结的.net的面试题。

说明:以下代码均已经过验证正确无误!

C#:

1.c#实现N的阶乘:

class Program
{
static void Main(string[] args)
{
int n = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(jiechengN(n));
Console.ReadKey();
}
public static double jiechengN(int n)
{
if (n == )
{
return ;
}
else
{
return n * jiechengN(n - );
}
}
}

2.求一下表达式的值:1-2+3-4+5….+m

       int m = ;
int count = ;
for (int i; i <= m; i++)
{
if (i % == )
{
count += i;
}
else
{
count -= i;
}
}

3.产生一个int数组,长度为100,并向其中随机插入1-100,并且不能重复。

       int[] intarr = new int[];
  ArrayList mylist = new ArrayList();
Random rdm = new Random();
while (mylist.Count < )
{
int num = rdm.Next(, );
if (!mylist.Contains(num))
mylist.Add(num);
}
for (int i = ; i < ; i++)
{
intarr[i] = (int)mylist[i];
}

4.一列数的规则如下: 112358132134......  求第30位数是多少, 用递归算法实现。

static void Main(string[] args)
{
Console.WriteLine(qiu30());
Console.ReadKey();
}
public static int qiu30(int i)
{
if (i <= )
{
return ;
}
else
{
return qiu30(i - ) + qiu30(i - );
}
}

5.请编程遍历页面上所有TextBox控件并给它赋值为string.Empty

Foreach(system.windows.forms.control cont in this.Controls)
{
If(cont is system.windows.forms.textbox)
    {
    System.windows.form.textbox tb=system.windows.form.textbox(cont);
    Tb.text=string.empty;
    }
}

6.冒泡排序

static void Main(string[] args)
{
//int num=6;
int[] array= new int[];
for (int i = ; i < ; i++)
{
array[i] = Convert.ToInt32(Console.ReadLine());
}
maopao(array);
for (int n = ; n < array.Length; n++)
{
Console.WriteLine(array[n]);
}
Console.ReadKey();
}
public static void maopao(int[] array)
{
for (int i = ; i < array.Length - ; i++)
{
for (int j = ; j < array.Length - i - ; j++)
{
if (array[j] < array[j + ])
{
int temp = array[j];
array[j] = array[j + ];
array[j + ] = temp;
}
}
}
}

SQL:

1.计算及格率:

select name,convert(varchar(10),round(SUM(case when score >=60 then 1 else null end)*100/COUNT(*),2))+ '%' as 及格率 from Class group by Name

2.查询出来 再插入

insert into Class (Name,Score) select class_id,num from score

3. 写出一条Sql语句:取出表A中第31到第40记录(SQLServer,以自动增长的ID作为主键,注意:ID可能不是连续的。)

方法一:select top 10 * from A where id not in (select top 30 id from A)
方法二:select top 10 * from ( select top 10 * from (select top 40 * from A order by ID) t order by ID desc) s order by id asc

4.查询学生姓名,并且查询分数,当分数大于等于90时显示为优,当分数大于等于80且小于90时显示为良,当分数大于等于60且小于80时显示为中,当分数小于60时显示为差。

select name,(case when score>=90 then '优' when score between 80 and 89  then '良'  when score between 60 and 79 then '中' else '差' end) as 成绩 from class

5. left join right join inner join 区别

left join(左联接) 返回包括左表中的所有记录和右表中联结字段相等的记录
right join(右联接) 返回包括右表中的所有记录和左表中联结字段相等的记录
inner join(等值连接) 只返回两个表中联结字段相等的行

6. sql 查询表中姓名重复的数据

select name from class group by name having COUNT(name)>1

7. SQL行转列

select * from Class

转换后:

select name,SUM(case classname when '语文' then score else 0 end) as 语文,
SUM(case classname when '英语' then score else 0 end) as 英语,
SUM(case classname when '数学' then score else 0 end) as 数学
from Class group by Name

JQuery:

1.把所有 p 元素的背景颜色更改为红色

$("p").css("background-color","red");

2.Jquery实现全选和取消

<input type='checkbox' id='id1' name='checkname[]' value='1' />value1
<input type='checkbox' id='id2' name='checkname[]' value='2' />value2
<input type='checkbox' id='id3' name='checkname[]' value='3' />value3 <input type="button" id="checkall" name="checkall" value="全选" />
<input type="button" id="delcheckall" name="delcheckall" value="取消全选" /> $(“#checkalll”).click(
Function(){
If(this.checked)
{
$(“input[name=’checkname’]”).attr(‘checked’,true)
}
Else
{
$(“input[name=’checkname’]”).attr(‘checked’,false)
}
}
);

3.判断radioselelctcheckbox是否选中

Var  radioVal=$(‘input:radio[name=”sex”]:checked’).val();
If(radioVal ==null)
{
Alert(“没有选择”);
Return false;
}
Else
{
Alert(“已选中);
} Var selectVal=$(‘select[name=selectID]’).val(); If($(“#checkbox1”).is(“:checked”))

最新文章

  1. swiper框架,实现轮播图等滑动效果
  2. Centos5, 6下更改系统时间和时区
  3. 安装SQL Server 2008 R2 Enterprise错误:&#39;&#39; is not a valid login or you do not have permission
  4. 【ruby】ruby基础知识
  5. hive操作语句使用详解
  6. POJ 3318 Matrix Multiplication(矩阵乘法)
  7. [selenium webdriver Java]常用api
  8. 牛刀小试、用SharePoint 实现请假管理功能
  9. Shell上传文件到ftp
  10. Boost使用笔记(Smart_ptr)
  11. c++ 10
  12. unity读取Sqlite数据库
  13. 记2014“蓝桥杯全国软件大赛&amp;quot;决赛北京之行
  14. 在Debian 8 上安装自动化工具Ansible
  15. NIO相关基础篇三
  16. 搭建非域AlwaysOn win2016+SQL2016
  17. 小甲鱼Python3笔记
  18. java虚拟机学习
  19. 使用openpyxl实现excel文件的读取操作
  20. 背水一战 Windows 10 (62) - 控件(媒体类): InkCanvas 保存和加载, 手写识别

热门文章

  1. Linux下使用cut切割有规则的列文本
  2. 使用参数化查询防止SQL注入漏洞
  3. POJ 3680 Intervals(费用流)
  4. vue-router 2.0 改变的内容
  5. 【spring cloud】spring cloud打包最外层项目报错:&#39;packaging&#39; with value &#39;jar&#39; is invalid. Aggregator projects require &#39;pom&#39; as packaging. @ line 9, column 13
  6. exVim安装
  7. 剖析ASP.NET Core MVC(Part 1)- AddMvcCore(译)
  8. TCP的状态(SYN,FIN等)
  9. 记一次vue2项目部署nginx静态文件404解决过程
  10. 一般源码安装添加的GD库 是不支持 jpeg 格式的图片的