部分IT公司笔试算法题
[10-10 21:21:19] 来源:http://www.77xue.com 笔试题目 阅读:8903次
概要:if(str!=c) str[j++]=str;str[j] = '\0';}int main(int argc, char* argv[]) {char str[] = "abcdefgh"; // 注意,此处不能写成char *str = "abcdefgh";printf("%s\n", str);delChar(str, 'c');printf("%s\n", str);}26、判断单链表中是否存在环(网上说的笔试题)#include "stdafx.h"typedef char eleType; // 定义链表中的数据类型typedef struct listnode { // 定义单链表结构eleType data;struct listnode *next;}node;node *create(int n) { // 创建单链表,n为节点个数n
部分IT公司笔试算法题,标签:驾照笔试题目,腾讯笔试题目,http://www.77xue.com
if(str!=c) str[j++]=str;
str[j] = '\0';
}
int main(int argc, char* argv[]) {
char str[] = "abcdefgh"; // 注意,此处不能写成char *str = "abcdefgh";
printf("%s\n", str);
delChar(str, 'c');
printf("%s\n", str);
}
26、判断单链表中是否存在环(网上说的笔试题)
#include "stdafx.h"
typedef char eleType; // 定义链表中的数据类型
typedef struct listnode { // 定义单链表结构
eleType data;
struct listnode *next;
}node;
node *create(int n) { // 创建单链表,n为节点个数
node *p = (node *)malloc(sizeof(node));
node *head = p; head->data = 'A';
for(int i='B'; i<'A'+n; i++) {
p = (p->next = (node *)malloc(sizeof(node)));
p->data = i;
p->next = NULL;
}
return head;
}
void addCircle(node *head, int n) { // 增加环,将链尾指向链中第n个节点
node *q, *p = head;
for(int i=1; p->next; i++) {
if(i==n) q = p;
p = p->next;
}
p->next = q;
}
int isCircle(node *head) { // 这是笔试时需要写的最主要函数,其他函数可以不写
node *p=head,*q=head;
while( p->next && q->next) {
p = p->next;
if (NULL == (q=q->next->next)) return 0;
if (p == q) return 1;
}
return 0;
}
int main(int argc, char* argv[]) {
node *head = create(12);
addCircle(head, 8); // 注释掉此行,连表就没有环了
printf("%d\n", isCircle(head));
}
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9]
Tag:笔试题目,驾照笔试题目,腾讯笔试题目,求职指南 - 求职笔试面试 - 笔试题目
- 上一篇:IT公司笔试常考的算法题
《部分IT公司笔试算法题》相关文章
- 部分IT公司笔试算法题
- › 部分IT公司笔试算法题
- › 部分IT公司常考的算法题目
- 在百度中搜索相关文章:部分IT公司笔试算法题
- 在谷歌中搜索相关文章:部分IT公司笔试算法题
- 在soso中搜索相关文章:部分IT公司笔试算法题
- 在搜狗中搜索相关文章:部分IT公司笔试算法题