📄 algorithm_two_five.cpp
字号:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define Elemtype int
typedef struct{
Elemtype *elem;
int Lenth;
}Sqlist;
char InitList(Sqlist &L)
{
L.elem=(Elemtype *)malloc(11*sizeof(Elemtype));
if(L.elem==NULL) return 0;
L.Lenth=10;
return 1;
}
char ListDelete(Sqlist &L,int i)
{
Elemtype *P,*Q;
if (i<0||i>L.Lenth-1) return 0;
P=L.elem+L.Lenth-1;//要引用数据结构中的变量时必须通过结构体对象明
Q=&L.elem[i];
for(;Q<=P-1;Q++)*Q=*(Q+1);
L.Lenth--;
return 1;
}
void main()
{
Sqlist K;
InitList(K);
ListDelete(K,2);
printf("%d",K.Lenth);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -