17070047 / 17070047/CodeStructureCourse

苏欣晨

Offen
#74 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
C++
Sterne
16
Forks
2
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

```c
#include"stdio.h"
#include"stdlib.h"
#include"string.h"
#define m 20
#define max 100
typedef struct studentnode {
char cardnum[m];
char name[m];
char classnum[m];
char college[m];
}node;
typedef struct {
node r[max + 1];
int length;
}table;
void sort(table *tab, int left, int right)
{
int i, j;
if (leftr[0] = tab->r[i];
do
{
while (strcmp(tab->r[j].cardnum, tab->r[0].cardnum) == 1)j--;
if (ir[i] = tab->r[j];
i++;
}
while (strcmp(tab->r[i].cardnum, tab->r[0].cardnum) == -1)i++;
if (ir[j] = tab->r[i]; j--;
}
} while (i != j);
strcmp(tab->r[i].cardnum, tab->r[0].cardnum);
sort(tab, left, i - 1);
sort(tab, i + 1, right);
}
}
void creat(table *tab)
{
int i, j, k;
printf("请输入结点个数:\n");
scanf("%d", &tab->length);
tab->length++;
getchar();
for (i = 1; ilength; i++)
{
printf("请输入卡号:\n");
gets(tab->r[i].cardnum);
printf("请输入名字:\n");
gets(tab->r[i].name);
printf("请输入班号:\n");
gets(tab->r[i].classnum);
printf("请输入系别:\n");
gets(tab->r[i].college);
}
printf("创建完成\n");
}
void find(table *tab)
{
int i, j;
char object[m];
printf("请输入你要查找的系别:\n");
gets(object);
for (i = 0; ilength; i++)
{
if (strcmp(object, tab->r[i].college) == 0)
{
puts(tab->r[i].cardnum);
puts(tab->r[i].name);
puts(tab->r[i].classnum);
puts(tab->r[i].college);
}
}
}
void display(table *tab)
{
int i;
for (i = 1; ilength; i++)
{
puts(tab->r[i].cardnum);
puts(tab->r[i].name);
puts(tab->r[i].classnum);
puts(tab->r[i].college);
}
}
int main()
{
int i;
table *tab;
tab = (table *)malloc(sizeof(table));
creat(tab);
sort(tab, 1, tab->length - 1);
display(tab);
while (scanf("%d", &i) != EOF)
{
getchar();
find(tab);
}
return 0;
}
```

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

The issue contains a C program with a sorting function and student record management. The bug is not explicitly stated; examine the sort function's logic, particularly the use of strcmp return values and the recursive calls. Run the program to see if it crashes or sorts incorrectly. Look for memory leaks or incorrect array indexing.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
c
Bereich
cli
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
20/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.