贵州旅游攻略?
500
2024-04-29
*elem;
int length;
int listsize;
} Sqlist;
status Create_sq(Sqlist *L,int n)
{
int i;
L->elem=(int*)malloc(100*sizeof(int));
if(!L->elem) return 0;
for(i=0;iscanf(%d,&(L->elem[i])); L->length=n; L->listsize=100; return 1; } status Listinsert_sq(Sqlist *L,int i,int e) { int *q,*p,*newbase; if(i<1||i>L->length+1) return 0; if(L->length>=L->listsize) { newbase=(int*)realloc(L->elem,(L->listsize+10)*sizeof(int)); if(!newbase) exit(-2); L->elem=newbase; L->listsize+=10; } q=&(L->elem[i-1]); for(p=&(L->elem[L->length-1]);p>=q;--p) *(p+1)=*p; *q=e; ++L->length; return 1; } int main() { Sqlist L1; int n,a; int i,e; printf(\n please input the number of data:\n); scanf(%d,&n); if(Create_sq(&L1,n)==1) { scanf(%d%d,&i,&e); a=Listinsert_sq(&L1,i,e); if(a==1) printf(insert success\n); else printf(insert false\n); printf(the list elements are:\n); for(i=1;i<=L1.length;i++) { printf(%d\t,L1.elem[i-1]); } } return 0; }
vb6代码:在form1上画一个textbox1和一个command1即可:textbox1用于接收键盘输入的10个整数:
Private Sub Command1_Click()
Dim a As String, b() As String
a = Trim(Text1.Text)
b() = Split(a, ,)
For c = 0 To UBound(b)
Print 第 & c + 1 & 个数= & b(c) & vbCrLf
Next c
End Sub