新人求帮忙
//InitList_Sq.cpp
#include<stdlib.h>
#include<malloc.h>
#include<iostream>
#include<conio.h>
using namespace std;
#define LIST_INIT_SIZE 100
#define LISTINGCREMENT 10
typedef struct
{ int*elem
int length;
int listsize;
} SqList;
int InitList_Sq(SqList&L) //InitList_Sq()function
{//Inititial a Sq_List
L.elem=(int*)malloc(LIST_INIT_SIZE*sizeof(int));
if(!L. elem)return(0);
L.length =0;
L.litssize=LIST_INIT_SIZE;
return(1);
}//end of InitList_Sq()function
void main()
{
SqList L;
cout<<"InitList_Sq.cpp"<<endl<<" =========="<<endl<<endl;
if(!InitList_Sq(L)
cout<<"Falure to Initialize a Sq_List!"<<endl;
else
count<<"Success to Initialize a Sq_List!"<<endl;
getch();
}//end of main()function
数据结构,老师要求解释,但是没学C语言,根本搞不懂,请各位帮帮忙
还有就是数据结构和C语言,还有C#他们该这么学,先学谁,学校开了这几门课。
[解决办法]
基础语法看看,也就一个下午的时间。。。。。。
[解决办法]
#include<stdlib.h>#include<malloc.h>#include<iostream>#include<conio.h>using namespace std;#define LIST_INIT_SIZE 100#define LISTINGCREMENT 10typedef struct{ int*elem; int length; int listsize;} SqList;int InitList_Sq(SqList&L) //InitList_Sq()function{//Inititial a Sq_List //elem指针申请空间 L.elem=(int*)malloc(LIST_INIT_SIZE*sizeof(int)); //申请不成功 返回0 if(!L. elem) return(0); //赋值 L.length =0; L.listsize=LIST_INIT_SIZE; return(1);//成功返回1}//end of InitList_Sq()functionvoid main(){ SqList L; cout<<"InitList_Sq.cpp"<<endl<<" =========="<<endl<<endl; if(!InitList_Sq(L)) cout<<"Falure to Initialize a Sq_List!"<<endl; else cout<<"Success to Initialize a Sq_List!"<<endl; getch();}//end of main()function