re: 微创面试归来话感想 aspnetx 2006-08-04 10:22
微创早先早我们学校招聘过
不过似乎结果很是不好,都是外包,而且去的都是理学院的,反而我们计算机的一个也没去上.
关键是人家要啥样的了,去了市场不一定是买菜的对吧
并不需要指针的知识
正如上楼所说,得是一个排好序的数组才可以用二分法。
排序 升序or降序都无所谓
二分法的好处是减少查找所需数的次数,降低编译时间
列子:数组a[5]={1,2,3,4,5};
用二分法查2
设两个值high=4, low=0 mid=(high+low)/2 a[mid]=3
此时发现2<a[mid];
则low=0不变,high=mid;
就按这个方法逐步寻找;
这就是二分法。
re: 46家中外知名企业面试题目 Ansel 2006-08-01 14:59
#i nclude <iostream>
using namespace std;
class node
{
public:
node(int x):data(x),next(0){}
int data;
node* next;
};
node* ReversList(node* head)
{
node* p=0;
node* q=head;
while(head->next!=0)
{
p=head->next;
head->next=p->next;
p->next=q;
q=p;
}
return q;
}
int main()
{
node* head=new node(0);
node* tail=head;
for(int i=1;i<10;i++)
{
node* p=new node(i);
tail->next=p;
tail=p;
}
head=ReversList(head);
while(head->next!=0)
{
cout<<head->data<<endl;
head=head->next;
}
getchar();
return 0;
}
re: 46家中外知名企业面试题目 Ansel 2006-08-01 14:31
关于链表倒置:
#include<iostream.h>
typedef struct Lnode
{
int data;
Lnode* next;
}Lnode;
Lnode* CreateList()
{
int n;
cout<<"请输入要创立的链表的长度:";
cin>>n;
Lnode *L,*p;
L=new Lnode;
L->next=NULL;
for(int i=n;i>0;i--)
{
p=new Lnode;
cout<<"请输入数据:";
cin>>p->data;
p->next=L->next;
L->next=p;
}
return L;
}
Lnode* CreateList1()
{
Lnode* L;
L=new Lnode;
L->next=NULL;
Lnode* p=L;
int n;
cout<<"请输入要创建链表的长度:";
cin>>n;
for(int i=1;i<=n;i++)
{
Lnode* q;
q=new Lnode;
cout<<"请输入该接点的数据:";
cin>>q->data;
q->next=NULL;
p->next=q;
p=p->next;
}
return L;
}
void ListDisplay(Lnode* L)
{
while(L->next)
{
L=L->next;
cout<<L->data<<" ";
}
cout<<endl;
}
int ListLength(Lnode* L)
{
int N=0;
while(L->next)
{
N++;
L=L->next;
}
return N;
}
void ListDaoZhi(Lnode* L)
{
int n;
Lnode* p=L;
n=ListLength(p);
Lnode* t=L->next;
Lnode* q=L->next;
for(int i=1;i<n;i++)
{
if(n!=2)
{
q=t;
for(int j=1;j<n-i;j++)
{
q=q->next;
}
if(j==n-2)
L->next=q->next->next;
q->next->next=q;
}
else
{
L->next=q->next->next;
q->next->next=q;
}
}
t->next=NULL;
}
void main()
{
Lnode* H;
H=CreateList1();
ListDisplay(H);
ListDaoZhi(H);
ListDisplay(H);
H=CreateList();
ListDisplay(H);
ListDaoZhi(H);
ListDisplay(H);
}
re: 46家中外知名企业面试题目 Ansel 2006-08-01 13:58
2006年5月20日
参加微创的笔试面试
威海路755号 文新报业大厦40层,2号线石门一路下(4号口)。
在40层做笔试的感觉:一览众山下,心情豁达开朗 :>
职位:高级软件工程师
3点到4点笔试(共两题)
1.有一个整数数组,例如:1,2,3
请编写一个函数,得到构成三角形的个数,并将这些三角形打印出来。
2.已知链表的头指针,如何判断该链表是循环链表。
解释:由1,2,3,2这四个节点构成的链表就称为循环链表
按时完成笔试,
感觉第2题做得比较好,
a>找最简单一个循环链表,即自己指向自己
b>用一个递归函数实现recrusion(Node* head)
第1题:
a>找规则,两边之和大于第三边
第2题:
设有两个结点指针 a,b 。
将其均初始化为链表的 head 指针。
然后循环进行如下操作:
将 a 前向移动 1 个结点,b 前向移动 2 个结点。
若过程遇到空结点或后面没有结点,则为非循环链表,出循环。
若 b == a 则为循环链表,出循环;否则继续循环。
----------------------------------------------
第一题解:
#include <algorithm>
#include <cstdlib>
#include <ctime>
using namespace std;
void make_triangle(int e[], int n)
{
int num = 0;
sort(e, e + n);
for (int i = 0; i < n - 2 ; i++)
for (int j = i+1; j < n - 1; j++)
for (int k = j+1; k < n; k++)
{
if (e[j] + e[i] > e[k])
printf("case %d:%d,%d,%d\n",++num, e[i],e[j],e[k]);
else
break;
}
}
int main()
{
srand(time(0));
int n = rand() % 10 + 3;
int *e = new int[n];
for (int i = 0; i < n; i++)
e[i] = abs(rand()) %100;
make_triangle(e,n);
delete e;
return 0;
}
case 1:36,63,71
case 2:36,63,76
case 3:36,63,78
case 4:36,63,82
case 5:36,63,84
case 6:36,63,93
case 7:36,71,76
case 8:36,71,78
case 9:36,71,82
case 10:36,71,84
case 11:36,71,93
case 12:36,76,78
case 13:36,76,82
case 14:36,76,84
case 15:36,76,93
case 16:36,78,82
case 17:36,78,84
case 18:36,78,93
case 19:36,82,84
case 20:36,82,93
case 21:36,84,93
case 22:63,71,76
case 23:63,71,78
case 24:63,71,82
case 25:63,71,84
case 26:63,71,93
case 27:63,76,78
case 28:63,76,82
case 29:63,76,84
case 30:63,76,93
case 31:63,78,82
case 32:63,78,84
case 33:63,78,93
case 34:63,82,84
case 35:63,82,93
case 36:63,84,93
case 37:71,76,78
case 38:71,76,82
case 39:71,76,84
case 40:71,76,93
case 41:71,78,82
case 42:71,78,84
case 43:71,78,93
case 44:71,82,84
case 45:71,82,93
case 46:71,84,93
case 47:76,78,82
case 48:76,78,84
case 49:76,78,93
case 50:76,82,84
case 51:76,82,93
case 52:76,84,93
case 53:78,82,84
case 54:78,82,93
case 55:78,84,93
case 56:82,84,93
第二题解:
bool check_circle_list(Circ* head)
{
Circ *p,*q;
*p=head;
*q=head-link;
while(p&&q)
{
if(p==q) return true;
*p=*p->link;
*q=*q->link->link;
}
return false;
}
问题:执行删除操作时候,出现异常但是“由于安全限制,无法访问类型System.Runtime.Remoting.ObjRef”,请问错误出在哪?如何解决?
详细的情况如下:
1、先定义了一个接口
public interface IDataBaseOperator
{
int Update( object sender );
int Add( object sender );
int Delete( object sender );
DataSet Select( string selectCondition, bool selMode );
}
用于对数据库执行4种操作
2、然后在定义一远程对象
public class Customers: MarshalByRefObject,IDataBaseOperator
3、构建宿主程序,使用配置文件
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.runtime.remoting>
<application>
<service>
<wellknown
mode="SingleCall"
type="CustomersLibrary.Customers, CustomersLibrary"
objectUri="Customers" />
</service>
<channels>
<channel port="8086" ref="tcp"/>
</channels>
<!--leaseManagerPollTime="7S"-->
<lifetime
leaseTime="7M"
sponsorshipTimeout="7M"
renewOnCallTime="7M"
/>
</application>
</system.runtime.remoting>
</configuration>
4、构建客户端,也使用配置文件
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.runtime.remoting>
<application>
<client>
<wellknown type="Customers, CustomersLibrary" url="tcp://192.168.1.18:8086/Customers" />
</client>
<channels>
<channel ref="tcp" port="0"></channel>
</channels>
</application>
</system.runtime.remoting>
</configuration>
执行操作
{
RemotingConfiguration.Configure( AppDomain.CurrentDomain.SetupInformation.ConfigurationFile );
Customers obj2 = new Customers();
if (obj2 == null)
{
System.Console.WriteLine(
"Could not locate TCP server");
}
try
{
obj2.ID = "123456-123456";
obj2.Delete(obj2);
}
catch ( Exception ex )
{
MessageBox.Show(ex.Message);
}
}
但是系统提示“由于安全限制,无法访问类型System.Runtime.Remoting.ObjRef”,请问错误出在哪?如何解决?谢谢!
re: ASP.NET 2.0 的内部变化 Ansel 2005-08-31 11:58
ASP.NET 2.0 Tips(1):跨页投递
在ASP.NET 1.x的时候,很多朋友可能需要进行跨页提交的处理,也就是从页面A能够提交到页面B,甚至不同的Control其目标处理页面也各不相同。尤其是从ASP/JSP/PHP转过来的开发人员,可能更有这种需求。但很不幸,在ASP.NET 1.x的时候,处理这种跨页请求是十分丑陋的,需要非常多的“技巧化”处理。
在ASP.NET 2.0的时候,对于跨页提交已经有了非常合理的解决方案,以下就是一个示例。
SourcePage.aspx: 请注意Button1的PostBackUrl属性设置
<%...@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">...
public string YourName
...{
get
...{
return this.TextBox1.Text;
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="请输入您的姓名" Width="183px"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="提交" PostBackUrl="~/TargetPage.aspx" /></div>
</form>
</body>
</html>
TargetPage.aspx:请注意PreviousPageType的属性设置
<%...@ Page Language="C#" %>
<%...@ PreviousPageType VirtualPath="~/SourcePage.aspx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">...
protected void Page_Load(object sender, EventArgs e)
...{
this.Label1.Text = PreviousPage.YourName;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" ></asp:Label>
</div>
</form>
</body>
</html>
OK,就通过这么简单的两个属性设置,就可以非常方便的得到跨页提交的特性。当然,您也可以根据您自己的需求,比如每个Control需要提交到不同的页面来进行更加复杂的设置。