
常见笔试题
文章平均质量分 65
半岛铁盒.
如果遇到10年前的自己,你最想对他说什么
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
有n个人围成一圈,顺序排号,从第一个开始报数(从1到3报数),凡报到3的人退出圈子,问最后留下的是原来第几号的那位?
#include #include typedef struct Node { int data; struct Node *next; }Node; typedef Node* Linklist; Linklist L; /* 定义全局变量头指针 */ void Initlist() { L=NULL; printf("初始化成功!建立了一个空链表L原创 2018-01-24 21:26:04 · 501 阅读 · 0 评论 -
建立单链表,把’a'–’z’26个字母插入,倒叙,打印
#include <stdio.h> #include <stdlib.h> typedef struct Node { char data; struct Node *next; }Node; typedef Node* Linklist; Linklist L; void Initlist() { L=NULL; printf("初始化链表为空!\n"); } i...原创 2018-01-26 15:19:33 · 2356 阅读 · 1 评论 -
写个函数,判断单链表是否有环
思路:定义两个指针起始值为链表的头指针,分别为fast,slow,fast指针要比slow指针移动快一步,如果fast指针首先移动到NULL,则说明链表没有环,如果出现fast==slow的情况则说明链表有环,fast指针比slow指针快了一圈,刚好相遇 void Boollist(Linklist L) { Linklist fast=L; Linklist slow=L; while原创 2018-01-28 18:33:19 · 491 阅读 · 0 评论 -
输入5个数(含有负数,小数)将他们由小到大排序
#include float paixu(float b[]) //选择排序 { int i,j,min; float temp; int len=sizeof(b)/sizeof(b[0]); for ( i = 0; i { min=i; for (j = i+1;j { if(b[j] { min=j; } } if (min!=i) {原创 2018-01-28 20:44:45 · 552 阅读 · 0 评论 -
数组逆序
#include <iostream> #include <stack> #include <string.h> using namespace std; int* Daoxu(int *a,int len) { stack<int>s; for(int i=0;i<len;i++) { s.push(...原创 2018-07-18 20:06:17 · 199 阅读 · 0 评论 -
写一个函数,实现strstr,从一个字符串中,查找一个子字符串,如strstr("123456","34) 返回查到的子串是"34",位置在原字符串的位置是2号
#include <iostream> #include <assert.h> using namespace std; char *mystr(char *dest,char *src) { int count=0; //计数记录第一次子字符串出现的位置 assert(dest!=NULL); assert(src!=NULL); w...原创 2018-08-09 19:10:19 · 885 阅读 · 0 评论 -
彻底理解结构体struct和枚举union的内存对齐和大小计算
#include <iostream> using namespace std; typedef union { long i; //32位机占4个字节 int k[5]; //5个int占20个字节,一个int是4个字节 char c; //c实际只占一个字节,但由于内存对齐会给它分配4个字节的空间 }DATE; DATE D; struct d......原创 2018-08-11 11:21:57 · 412 阅读 · 1 评论