面试之C语言
C语言的一些经典题目
梧桐呓语ll
要一个完成,不要千万个开始
展开
-
函数指针的定义
1.函数指针的定义(要掌握这个就行了)原创 2019-06-09 19:37:38 · 118 阅读 · 0 评论 -
输入一个日期,输出第二天的日期
#include <stdio.h> #include <stdlib.h> //输入今天的日期,求明天的日期 // struct date{ int year; int month; int day; }; bool isLeap(struct date d); int numberOfDays(struct date d); int main(int arg...原创 2019-06-02 23:28:59 · 6216 阅读 · 1 评论 -
字符串的几个函数
关于字符串的函数总结:strlen(),strcmp(),strcpy(),strcat() 1.strlen() 函数 size_t strlen(const char* s) 返回s的字符串长度,不包括结尾的0 #include <stdio.h> #include <string.h> //对于字符数组遍历,比较重要的一个点就...原创 2019-05-30 22:00:17 · 750 阅读 · 0 评论 -
指针与二维数组 不理解的地方
#include <stdio.h> #include <stdlib.h> #include <string.h> //说实话,这个不理解,int(*p)[4]; 意思是定义一个数组指针! void print(int(*p)[4], int row){ int i, j; printf("sizeof(*p)=%d\n", sizeof(*p)); ...原创 2019-06-08 22:43:27 · 84 阅读 · 0 评论 -
C语言:对指针的一些总结
1.一级指针 指针的用途:传递和偏移 #include <stdio.h> #include <stdlib.h> //指针的本质是:间接访问!!!!! int main() { int i = 3; int *iPointer;//指针变量,int*型的 scanf("%d", &i); printf("%d\n", i);//直接访问 iPoin...原创 2019-06-09 00:38:44 · 78 阅读 · 0 评论 -
动态数组
动态数组 #include <stdio.h> #include <stdlib.h> #include <string.h> //真正的动态数组 #define CAPACITY 10 int main() { char *p=(char*)malloc(CAPACITY); char c; int i=0,cap=CAPACITY; while(...转载 2019-06-07 23:06:57 · 70 阅读 · 0 评论 -
对学生信息进行排序
1.用qsort #include <stdio.h> #include <stdlib.h> typedef struct{ int num; char name[20]; float chinese; float math; float english; }Student_t,*pStudent_t; #define N 5 int compareN...原创 2019-06-12 12:58:15 · 418 阅读 · 0 评论 -
关于递归的几个典型题目
1.台阶问题,也是斐波那契数列? (非递归的方法) f(n)=f(n-1)+f(n-2) 1 1 1种 2 1 1 2 2种 3 1 2 1 1 1 2 1 1+2=3种 4 ...原创 2019-06-10 20:18:15 · 714 阅读 · 0 评论 -
求一个字符串数组的最大值和次大值
#include <stdio.h> #include <stdlib.h> #include <string.h> //比较一组字符串数组的大小,并且从中找出最大值和次大值 void big(char **p, int N, char **p1, char **p2) { *p1 = strcmp(p[0], p[1]) > 0 ? p[0] : p...原创 2019-06-09 22:23:31 · 1406 阅读 · 1 评论 -
二级指针的偏移,索引式排序
增量编译 对b[5][12] = { "zhousi","chang'e","erlangshen","weinasi","liubei" }; 这里面的字符串,按字母表顺序从小到大打印出来 最初版本: 中间版本: #include <stdio.h> #include <stdlib.h> #include <s...原创 2019-06-09 20:29:07 · 453 阅读 · 0 评论 -
字符串翻转
题目描述:输入一串字符串: hello world 输出: world hello 方法1:指针做法: #include <stdio.h> #include <stdlib.h> #include <string.h> //解决思路:第一步:把字符串由hello world 变成...原创 2019-06-09 15:26:32 · 185 阅读 · 0 评论