++I am not sure I am solving this array based ADT list problem correctly in C

the code is not finished yet but i wanna make sure before i can continue that i am solving correctly

#include<iostream>
using namespace std;


struct element{

int position;
int value;

};

struct vector{
 element * e;
 int n;
 int maxsize;
};

void initializezero(Vector &v,int maxsize) //Make an empty integer vector 
{
v.e = new element[Max];
v.n=0;
v.Max=Max;
}
void initializen(Vector &v,int n,int maxsize) //Make a vector with n elements. 
{
v.e = new element[Max];
for(int i=0;i<n;i++){
v.e[i].value=0;
v.e[i].position=i;}
}
void initializenvalue(Vector &v,int n,int val,int maxsize) //Make a vector with n elements, initialized to  value.
{v.e = new element[Max];
for(int i=0;i<n;i++)
{
v.e[i].value=val;
v.e[i].position=i
}
}
void assign(Vector &v,int n,int val,int maxsize)
{
for(int i=0;i<n;i++)
{

v.e[i].value=val;
v.e[i].position=i;
}
}
void resize(Vector &v,int newsize)
{
 int *tmp = v.e;
 v.e=new element[newsize];
 
 for(int i=0;i<min(newsize,maxsize);i++)
 {v.e[i]=tmp[i];}
 
 maxsize=newsize;
 }


























 

أضف اجابة

أضف اجابة

‫تصفح