}
}
str[i] ^= str[j] ^= str[i] ^= str[j];
int main(int argc, char* argv[]) { }
25、删除串中指定的字符(做此题时,千万不要开辟新空间,否则面试官可能认为你不适合 做嵌入式开发) #include \
void delChar(char *str, char c) { }
int main(int argc, char* argv[]) {
int i, j=0;
for(i=0; str[i]; i++)
if(str[i]!=c) str[j++]=str[i];
char str[] = \printf(\change(str);
printf(\return getchar();
str[j] = '\\0';
char str[] = \// 注意,此处不能写成char
*str = \ }
26、判断单链表中是否存在环(网上说的笔试题) #include \typedef char eleType; 中的数据类型
typedef struct listnode { 表结构
eleType data;
struct listnode *next;
// 定义单链
// 定义链表
printf(\delChar(str, 'c'); printf(\
}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个节点 }
int isCircle(node *head) {
// 这是笔试
node *q, *p = head;
for(int i=1; p->next; i++) { }
p->next = q;
if(i==n) q = p; p = p->next;
时需要写的最主要函数,其他函数可以不写
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(\
}
// 注释掉此