Home > Back-end >  Order list output cannot lose out to answer
Order list output cannot lose out to answer

Time:09-27

#include
#include
#include
#include
using namespace std;
# define MaxSize 10

Struct City
{
Char number [50].
Char name [50].
Char shuoming [50].
};

Struct Sqlist
{
City data [MaxSize];
Int length;
};

Void CreateList (Sqlist * & amp; L, City a [], int n)
{
Int I=0, k=0;
L=(Sqlist *) malloc (sizeof (Sqlist));
While (i{
L - & gt; Data [I]=a, [k].
i++;
k++;
}
L - & gt; length;
}

Void DispList (Sqlist * l)
{
for(int i=0; i{
coutcoutcout}
}

Bool LocateElem (Sqlist * & amp; Int l, I, City e)
{
int j;
While (i<1 | | i> L - & gt; Length | | l - & gt; Length==MaxSize)
return false;
I -;
For (j=l - & gt; length; J> i; J -)
{
L - & gt; Data [j]=l - & gt; Data [1];
}
L - & gt; Data [I]=e;
L - & gt; Length++;
return true;
}

The main ()
{
Sqlist * l;
Struct City a [5]={{" 010 ", "Beijing", "Beijing, the capital"},
{" 021 ", "Shanghai", "Shanghai, municipality directly under the central government"},
{" 027 ", "wuhan", "wuhan, hubei province"},
{" 029 ", "xian", "xian, the capital of shaanxi province"},
{" 025 ", "working", "nanjing, the capital of jiangsu province"}};
CreateList (l, a, 5);
DispList (l);



}

  • Related