- 博客(7)
- 收藏
- 关注
原创 指针与二维数组
初次理解的二维数组与指针,请大家多多指教#include<stdio.h>int main(){ int aa[2][5] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; int *ptr1 = (int*)(&aa + 1); int *ptr2 = (int*)(*(aa + 1)); int *ptr3 = (int*)((aa +...
2018-03-30 19:51:41 162
原创 strcpy函数
#include<stdio.h>#include<assert.h>char*strcpy(char*strDest,const char *strSrc){ assert(strDest != NULL); assert(strSrc != NULL); char *strDestCopy=strDest; while ((*strDest++ = *strSrc++)...
2018-03-26 21:00:32 188
原创 蓝桥杯编程题
算法代码:#include<stdio.h>//a+b问题int main(){ int a, b; scanf_s("%d%d", &a, &b); printf("%d", a + b); return 0;}#include<stdio.h>//数列排序#include<stdlib.h>void Print(int *data, int ...
2018-03-16 22:01:13 1253
原创 杨辉三角
算法代码:#include<stdio.h>#define MAXN 40int n;int a[MAXN][MAXN];int main(){ int i, j; scanf("%d", &n); a[0][0] = 1; for (i = 0; i < n; ++i) { a[i][0] = a[i][i] = 1; for (j = 1; j < i; +...
2018-03-16 19:08:14 88
原创 二分查找
算法代码:#include<stdio.h>int binary_search(int*arr, int keynumber, int size){ int left = 0, right = size - 1; int mid; while (left <= right) { mid = (left + right) >> 1;//求两一处个数的平均值,这样写的目...
2018-03-15 18:54:38 131
原创 字符串处理的函数
一· strcpy函数的功能:将字符串复制到指定的数组中去。源代码:#include<stdio.h>#include<assert.h>char*strcpy(char*strDest,const char *strSrc){ assert(strDest != NULL);//指针不能为空! assert(strSrc != NULL); char *strDestCo...
2018-03-13 20:02:20 128
原创 杨氏矩阵
杨氏矩阵:一个二维数组,每一行从左到右递增,每一列从上到下递增。问题:若要从杨氏矩阵中查找一个数字,我们的思路是什么?答: 首先将要查找的数字和这个矩阵中最右上方的数字进行比较,若要找的数和最右上方的数字相等,则查找成功,若比它小,则剔除它所在的列,若比它大,则剔除它所在的行,直到找到想要查找的数字为止。此算法的代码如下:#include<stdio.h>#include<ass...
2018-03-13 20:01:39 164
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人