- 博客(7)
- 收藏
- 关注
原创 const
*定义常变量,只读不写基本数字类型对const是透明的在指针中修饰它的直接右边赋值号左边才用到它的权限权限的传递,权限可以等同或缩小传递,不可以放const在c语言中最主要的是不修改值的函数 指针形参前加const...
2020-10-18 20:21:49
51
原创 字符串复制
#include<stdio.h>void MyStrcpy(char *arr,char *brr)//方法一:数组{int i=0;while(arr[i]!=’\0’){brr[i]=arr[i];i++;}brr i=’\0’;}void MyStrcpy(char *arr,char *brr)//方法二:指针{while(*arr!=’\0’){*brr = * arr;arr++;brr++;}*brr=’\0’;}void MyStrcp
2020-10-16 08:11:48
1416
原创 约瑟夫问题
#include<stdio.h>#include<stdlib.h>typedef struct node{int data;struct node *next;}node;node *create(int n)//创建链表{node *p=NULL,*head;head=(node *)malloc(sizeof(node));p=head;node *s;int i=1;if(n!=0){while(i<=n){s=(node *)ma
2020-10-14 14:12:41
112
原创 swap交换函数
#include<stdio.h>void Swap(int *p,int *q){int temp;temp=*p;*p=*q;*q=temp;}void main(){int a,b;printf(“请输入\na,b\n”);scanf("%d,%d",&a,&b);Swap(&a,&b);printf(“a=%d b=%d\n”,a,b);
2020-10-12 22:22:18
442
2
原创 输出一个数的位数 逆序 每位数字
#include<stdio.h>#include<math.h>int Num_1(long long x)//求位数{int count;count=0;while(x!=0){x/=10;count++;}return count;}void Num_2(long long x)//逆序输出{while(x){if(x<0){x*=-1;}printf("%d “,x%10);x/=10;}}void Num_3(long
2020-10-12 17:33:19
667
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人