- 博客(7)
- 收藏
- 关注
原创 一维数组和二维数组不同情况下加一的不同数据类型
一维数组:int arr[4] 数据类型arr(表示首地址) int *xarr+1(表示加一的地址) ...
2019-03-04 22:27:40
910
原创 const的作用和规则
一、作用:定义常变量,不允许修改(只能作用于指针)二、规则:1、基本的数据类型对于const是透明的;例:int const ca=0;const int cb=0;ca和cb是等价的2、对于指针而言,const有三种地方可放例:const int p=&a;(限定p)int const p=&a;(限定p)int *const p=&a;(限定p)注:c...
2019-03-04 22:14:39
206
原创 指针加一的含义
给指针加一,一共只有四种情况:1、字节加一:指针是四个字节,如果指针加一是代表字节加一,那么会非常麻烦,一次只能往后走动一个字 节。2、整个数组加一:如果指针加一是代表加整个数组,这样就无法改变数组里的内容,一次性直接跳过了该数组,不好用。3、单元格加一:这样方便,好用,符合人们平时使用的习惯。...
2019-03-04 20:02:16
3834
原创 在长度为len的数组arr中查找关键字key,找到了返回下标,没有找到返回-1
#include <stdio.h>int BinSearch(int arr[],int len,int key){int low=0;int high=len-1;int mid;while (low<high){mid=(low+high)/2;if (arr[mid]==key){return mid;}else if (arr[mid]<...
2019-02-21 21:44:26
571
原创 冒泡排序法
#include <stdio.h>int BubbleSort(int arr[],int len){int i;int j;int tmp;for (i=0;i<len-1;i++){for (j=0;j<len-1;j++){if (arr[j]>arr[j+1]){tmp=arr[j];arr[j]=arr[j+1];arr[j+1...
2019-02-21 21:42:40
105
原创 顺序输出
#include <stdio.h>#include <math.h>int GetFigures(int n){int court=0;while (n!=0){n=n/10;court++;}return court;}int main(int n){scanf("%d",&n);int a=GetFigures(n);int m...
2019-02-21 20:31:27
419
原创 逆序输出123
#include <stdio.h>int main(){int x,m;x=123;while(x!=0){m=x%10;printf("%d",m);x/=10;}return 0;}
2019-02-21 20:05:44
1049
1
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人