自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(9)
  • 收藏
  • 关注

原创 编写静态顺序表(3) seqtable.c文件

#include "seqtable.h" //ST == struct SeqTable * //创建一个指定容量的顺序表 分配内存空间 fopen //返回NULL失败 如果成功返回顺序表的内存地址 ST create_seqtable(size_t cap){ ST st = (ST)malloc(STSIZE); //申请 struct SeqTable结构体的内存地址 if(st != NULL){ st->cap = cap;......

2022-06-30 23:39:57 109 1

原创 编写静态顺序表(2) seqtable.h文件

#ifndef _SEQ_TABLE_H__ #define _SEQ_TABLE_H__ #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <assert.h> #define SUCCESS 0 #define FAILURE -1 typedef int ElemType; //顺序表 struct SeqTable{ ElemType *elem...

2022-06-30 23:39:39 75

原创 编写静态顺序表(1) main.c文件

#include <stdio.h> #include <stdlib.h> #include <math.h> #include "seqtable.h" typedef void (*FUNC)(ST); void destroy(ST st){ destroy_seqtable(st); exit(0); } void printElem(ElemType *pe){ printf("%d ",*pe); } void show(ST...

2022-06-30 23:39:18 71

原创 写函数,在M*N个的格子里,左上角开始位置有一只蚂蚁,它每次只能往右或往下移动一格,求其到达右下角一共有多少种走法

#include <stdio.h> //递归策略 int count(size_t m,size_t n){ if(m==0 || n==0) return 0; if(m == 1 || n == 1){ return 1; } return count(m-1,n) + count(m,n-1); }

2022-06-29 23:43:19 331

原创 写函数,交换以下变量(2): (4)char *p1=“hello”;char *p2=“world”; (5)char s1[10]=“hello”;char s2[10]=“world”

//swap4(&p1,&p2); void swap4(char **pp1,char **pp2){ char *ps = *pp1; *pp1 = *pp2; *pp2 = ps; } //swap5(s1,s2); void swap5(char *s1,char *s2){ char tmp[strlen(s1)+1]; strcpy(tmp,s1); strcpy(s1,s2); strcpy(s2,t...

2022-06-29 23:43:05 184

原创 写函数,交换以下变量的值(1): (1):int a=1024,b=9527; (2):int *pa=&a,*pb=&b; (3):char m=‘a‘,n=‘b‘;

//swap1(&a,&b); void swap1(int *pa,int *pb){ int tmp = *pa; *pa = *pb; *pb = tmp; } //swap2(&pa,&pb); void swap2(int **ppa,int **ppb){ int *pt = *ppa; *ppa = *ppb; *ppb = pt; } //swap3(&m,&n); vo...

2022-06-29 23:42:37 63

原创 每日练习:写函数,把字符串逆序,并且把字符串循环左移n位

#include <stdio.h> //为了适配 moveRight 才添加的第二个参数 如果仅仅是逆序不需要第二个参数 void reverse(char *str,size_t len){ int i; for(i=0;i<len/2;++i){ char tmp = str[i]; str[i] = str[len-1-i]; str[len-1-i] = tmp; } } //HelloW...

2022-06-29 23:42:08 67

原创 每日练习:写函数,求一组整数的最大连续子串和 如:1 2 3 4 =>1+2+3+4 -2 -1 -3 => -1

#include <stdio.h> int maxSubSum(int arr[],size_t n){ int sum = arr[0]; //记录最大子串和 int currSum = 0; //当前累加和 int i; for(i=0;i<n;++i){ currSum += arr[i]; if(currSum > sum){ sum = currSum; ...

2022-06-29 23:38:37 64

原创 每日练习:写函数,给定年月日,这个日期是否有效,如果有效,请计算出下一天

#include <stdio.h> #include <stdbool.h> bool isValidDate(int year,int mon,int day){ //假设无效的 只需要找出有效的 int leap = year%4==0 && year%100!=0 || year%400==0; //闰年 leap为1 平年0 int littel = mon == 4 || mon == 6 || mon == 9 |...

2022-06-29 23:38:14 132 1

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除