c语言线性链表(C language linear list)
c语言线性链表(C language linear list)
# stdio.h > in <
# stdlib.h > in <
# string.h > in <
# define max _ length 35
typedef struct
{
char nb [15];
char name [15];
int c1, c2, c3;
} element;
element with _ (max length);
int n;
int sd ();
int inser _ sheet (int i, element with []);
int delete (int i, _ sheet element with []);
void print _ sheet element with a [], int n);
int locate _ sheet element with a [], int n, char x, []);
int chang _ sheet (int i, element with []);
er (void);
void main ()
{er ();
print _ leaf (s, n);
sd (a);
printf ("\ n% d", getchar ());
while (getchar () = = '')
{sd ();
getchar ();
}
}
int inser _ sheet (int i, element with [])
{
int j;
if (n = = max _ length) | | (< 1) | | (i > n + 1)) return (0);
for (j = n; j > = i; j -) with [j + 1] = s [j].
printf ("input data for inserting (nb name c1 c2 c3) \ n - >");
while (! (scanf ("% s% s% d% d% d", [even].nb, [even].name, & [i].c1, & [i].c2, & [i].c3)) & & scanf ("% s"))
printf ('\ t \ t - > - < 数据错误 ");
n + +; return (1);
}
int delete (int i, _ sheet element with [])
{
int j;
if ((< 1) | | (i > n) return (0);
for (j = i + 1; j < = n; j + +)
{
strcpy ([j - 1).nb with [j].nb); strcpy ([- 1].name with [j].name);
with [j - 1).c1 = s [j].c1; (j - 1).c2 = s [j].c2; (j - 1).c3 = s [j].c3;
}
n -; return (1);
}
void print _ sheet element with a [], int n)
{
int i;
if (n > max _ length) return;
printf ("well." tnb \ t \ tname \ t \ tc1 \ tc2 \ tc3 \ t ");
printf ("------------------------------------------------------------------------- \ n");
for (i = 1; i < = n; i + +)
printf ("%.2d \ t% \ t% \ t \ t% d% d \ t \ t% d \ t", i, [even].nb, [and].name, [even].c1, [even].c2, [even].c3);
}
int locate _ sheet element with a [], int n, char x [])
{
int i;
for (i = 1; i < = n; i + +) if (! strcmp (s [i].nb, x)) return (i);
return (0);
}
int chang _ sheet (int i, element with [])
{
if ((< 1) | | (i > max _ length + 1)) return (0);
printf ("input data for updating: \ n - >");
if (! scanf ("% s% s% d% d% d", [even].nb, [ev