一份面试题,大家来研究一下

浪漫幕末 2009-07-21 11:20:33
1. 常用的线性结构有哪些?数组和链表在内存中的存储特点是什么?栈和队列的操作原则是什么?
数组,链表,栈,队列
数组必须事先定义固定的长度(元素个数),不能适应数据动态地增减的情况。当数据增加时,可能超出原先定义的元素个数;当数据减少时,造成内存浪费。
链表动态地进行存储分配,可以适应数据动态地增减的情况,且可以方便地插入、删除数据项。(数组中插入、删除数据项时,需要移动其它数据项)
(静态)数组从栈中分配空间, 对于程序员方便快速,但是自由度小
链表从堆中分配空间, 自由度大但是申请管理比较麻烦.

栈是先进后出 FILO,队列是先进先出 FIFO

2. 判断一个表达式中左右括号是否匹配,采用哪种数据结构实现较为方便?

3. 为了提高队列的空间的使用效率,通常做怎么样的处理?
不知道
4. 说出下面几个C#函数的参数传递的区别?
1, private void test(string str){…} 传值
2, private void test(ref string str){…} 传地址
3, private void test(out string str){…} 输出参数
0
5. 把整数转换成中文字符串
System.Text.Encoding.GetEncoding("GB2312").GetString(System.Text.Encoding.Unicode.GetBytes(Convert.ToString("2")));
6. 在11个整数元素的数组(1-10)中寻找唯一重复的两个整数
数组a[N],存放整数1至N-1,其中某个数重复了一次。写一个函数,找出重复的数字。时间复杂度必须为O(N),函数原型:int do_dup(int a[],int N)
解答:
int do_dup(int a[],int N)
{
int temp;
//a[0]为监视哨
while (a[0]!=a[a[0]])
{
temp = a[0];
a[0] = a[temp];
a[temp] = temp;
}
return a[0];
}

7. SQL 定时操作,Group,Average,Top,Sum
不明白
8. C#中接口的使用场景
1、强制实现某种规范
2、应用多态,比如三层架构中数据访问工厂的实现
9. 用委托方法完成在一个类中封装四则运算
不会啊
10. 单链表的插入函数,语言不限
11. 字符串倒排的算法
ToCharArray()转换成char数组,再倒序。
12. 字符串第一个子串的匹配的算法
kmp算法,忘记了。。。
13.int add(double x)

int subtract(double x)

int multiplicat(double x)

double division(double x)

用委托的方法一次性的执行以上四个函数
委托要求返回值类型一样呀,不知道怎么搞。。。。

大家来补充,HOHO~
...全文
470 47 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
47 条回复
切换为时间正序
请发表友善的回复…
发表回复
jiangzhu1212 2009-07-28
  • 打赏
  • 举报
回复
收藏
wcqqq 2009-07-22
  • 打赏
  • 举报
回复
第11题:
#include <stdio.h>

char * my_strrev(char * str){

int len = 0;
/*计算字符串长度*/
while(*(str + (++len)) != '\0');

int i , l , j ;
for(i = 0 , j = len/2 , l = len - 1 ; i < j ; i++){

*(str + i) = *(str + i) ^ *(str + l - i);
*(str + l - i) = *(str + i) ^ *(str + l - i);
*(str + i) = *(str + i) ^ *(str + l - i);
}
return str;
}

int main(){

char * staticstr = "this is a static string";

int len = strlen(staticstr) + 1;

char * s = (char *)malloc(len);

memcpy(s , staticstr , len);

int i ;

printf("%s\n%s\n" , s , my_strrev(s));

/*函数执行的过程中会发生错误;
因为 staticstr被保存在了只读段,不允许修改;
可将 char * staticstr = "this is a static string"该为:
char staticstr[] = "this is a static string";
*/
printf("%s\n" , my_strrev(staticstr));

free(s);

s = NULL;

getch();
}
hackervip1988 2009-07-22
  • 打赏
  • 举报
回复
学习啦
数据结构学的太差啦
暑假补习一下拉
wcqqq 2009-07-22
  • 打赏
  • 举报
回复
第六题:
#include <stdio.h>

int findNum(int ary[] , int n){
int sum = 0 , arysum = 0;
int i;
for(i = 0 ; i < n ; i++){
arysum += ary[i];
sum += i;
}
return arysum - sum;
}

int main(){
int ary[11] = {1,2,3,4,5,7,6,7,8,9,10};

printf("%d\n" , findNum(ary,sizeof(ary)/sizeof(ary[0])));
getch();
}
wo554006164 2009-07-22
  • 打赏
  • 举报
回复
顶一个!!
wcqqq 2009-07-22
  • 打赏
  • 举报
回复
12题:
#include <stdio.h>
#include <stdlib.h>

//return the first appearance's index of string t in string s;
//if counld't find t in s then return -1;
int strpos(char *s, char *t){
int i, j, k;
for (i = 0; *(s+i) != '\0'; i++) {
for (j=i, k=0; *(t+k) !='\0' && *(s+j) == *(t+k); j++, k++);
if (k > 0 && *(t+k) == '\0')
return i;
}
return -1;
}


int main(){
char * ary[] = {
"salskdfjasld wcsq" ,\
"wcqasl;dkfja;sd",\
"aswcq",\
"sdfas",\
"sdfas",\
"sdfaswcq",\
"sdfwcqas"
};
char * findme = "wcq";

int i , j ;
//test strpos() function by call it in deferent conditions
for(i = 0 , j = sizeof(ary)/sizeof(char *); i < j ; i++){
printf("%d\n",strpos(ary[i] , findme));
}
system("pause");
}
wiki14 2009-07-22
  • 打赏
  • 举报
回复
挺牛的题目,学习了!
yang_kun 2009-07-22
  • 打赏
  • 举报
回复
进来学习了,,,,,,,,,,,,
love41349279 2009-07-22
  • 打赏
  • 举报
回复
down
yuanchangyuan2125 2009-07-22
  • 打赏
  • 举报
回复
SQL 定时操作 指 作业操作 创建一个作业 定时执行
springbell 2009-07-22
  • 打赏
  • 举报
回复
题目出得真的有水平,基础而重要,受教了,好好学习下
qq904492758 2009-07-21
  • 打赏
  • 举报
回复
顶一个。发现自己还有很多不懂得地方
jasondct 2009-07-21
  • 打赏
  • 举报
回复
顶 mark 学习。
messi_yang 2009-07-21
  • 打赏
  • 举报
回复
學習學習啊···
jdbcodbc 2009-07-21
  • 打赏
  • 举报
回复
UP
zzxap 2009-07-21
  • 打赏
  • 举报
回复
#include <stdio.h>

void char_T ( char c ) ; /*转化输出函数*/

int main()
{
char_T ( getchar ( ) ) ;
putchar ( '\n' ) ;
return 0 ;
}

void char_T ( char c )
{
if ( c != '\n' ) { /*递归调用*/
char_T ( getchar ( ) ) ;
}
c = c&223 ; /*字符大小写转换*/
if ( ( c > 90 ) || ( c < 65 ) )
return ;
putchar ( c ) ;
}
zzxap 2009-07-21
  • 打赏
  • 举报
回复
只写了个插入函数,其它都类似,如下

//头文件

#include <stdlib.h>
#include <stdio.h>

typedef struct NODE
{
struct NODE *link;
int value;
}Node;

//实现文件
#include "list.h"

#define FALSE 0
#define TRUE 1

//插入链表一个新元素,版本 1
int list_insert(Node **rootp, int new_value)//Node **rootp : 指向根指针的指针...
{
Node *current;
Node *previous;
Node *new_node;
/*其中, root 指针为根指针,它是指向链表第 1 个节点的指针
root 是一个指向 Node 的指针,所以参数的类型应该是Node**
*/
//得到第 1 个节点的指针
current = *rootp;
previous = NULL;

//寻找正确的插入位置
while (current != NULL && current->value < new_value)
{
previous = current;
current = current->link;
}

//为新结点分配内存
new_node = (Node*)malloc(sizeof(Node));
if (new_node == NULL)
return FALSE;
new_node->value = new_value;

//把新结点插入链表中
new_node->link = current;
if (previous == NULL) //判断是否应该插入到头节点
*rootp = new_node;
else
previous->link = new_node;

return TRUE;
}//在许多其它语言中,这是最佳方案,但是我们还可以做的更好一些,因为C允许我们获得现存对象的地址
int new_insert(register Node **linkp, int new_value)
{//这个插入函数更高效
register Node *current;
register Node *new_node;

while ((current = *linkp) != NULL && (current->value < new_value))
linkp = ¤t->link;

/*长度稍长易懂但不够简练的循环如下:
current = linkp;
while (current != NULL && current->value < value)
{
linkp = ¤t->link;
current = *linkp;
} //*/

new_node = (Node*)malloc(sizeof(Node));
if(new_node == NULL)
return FALSE;
new_node->value = new_value;

new_node->link = current;
*linkp = new_node;

return TRUE;
}

int main(void)
{
Node *root = NULL;
Node *tmp = NULL;
list_insert(&root, 23);
list_insert(&root, 32);
new_insert(&root, 5);
new_insert(&root, 5);
new_insert(&root, 6);
new_insert(&root, 15);
new_insert(&root, 3);

for (tmp = root; tmp != NULL; tmp = tmp->link)
{
printf("%d\n", tmp->value);
}


return EXIT_SUCCESS;
}
Hide1984 2009-07-21
  • 打赏
  • 举报
回复
JF~
超维电脑科技 2009-07-21
  • 打赏
  • 举报
回复
来学习下
wwd252 2009-07-21
  • 打赏
  • 举报
回复
加载更多回复(27)

62,243

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧