Home > Back-end >  C language bosses help me this poor primary school the younger sister! Ahhh!!! Is going to go crazy!
C language bosses help me this poor primary school the younger sister! Ahhh!!! Is going to go crazy!

Time:09-16

Program: then task 2, assuming that there is a text file STUDENT. TXT, which store information on a number of students, each STUDENT information include: STUDENT id, name, and mathematics, politics and the English homework three grades and divide, but unknown number of students, STUDENT information in the file is read to the structure in the linked list, and divided the highest output the STUDENT's name and STUDENT id, requirements:
A. in structure type student's student id, name, and mathematics, politics and the English homework three grades and divide,
B. a number of students in the form of a list, read a student information, is a dynamic application space, and then link to the chain table,
Beg code agghh!!!!!!!!!!

CodePudding user response:

Write about yourself first, otherwise, how to improve and progress ~

CodePudding user response:

The
reference 1/f, confident boy reply:
write about yourself first, otherwise how to improve and progress ~

Say so, is really couldn't write the

CodePudding user response:

Primary school the younger sister don't panic

 # include & lt; Stdio. H> 
#include
#include

Struct Stu
{
Char no [20].
Char name [10].
Float math;
Float here;
Float English;
Float business;
Struct Stu * next;
};

Int main (void)
{
The FILE * fp.
Fp=fopen (" student. TXT ", "r");
if (! Fp)
{
Printf (" file open failed ");
exit(0);
}
Struct Stu * head=(struct Stu *) malloc (sizeof (struct Stu));
Struct Stu * TMP;
The head - & gt; Next=NULL;
Char no [20].
Char name [10].
Float math;
Float here;
Float English;
Float business;
While (fscanf (fp, "% s \ \ t t % s, % f, % f, % f \ t \ \ t t % f", no, name, & amp; Math, & amp; Here, & amp; English, & amp; Business)!=(EOF)
{
TMP=(struct Stu *) malloc (sizeof (struct Stu));
TMP - & gt; Next=NULL;
If (TMP)
{
Strcpy (TMP - & gt; No, no);
Strcpy (TMP - & gt; The name, name);
TMP - & gt; Math=math;
TMP - & gt; Here=here;
TMP - & gt; English=English;
TMP - & gt; Business=business;
TMP - & gt; Next=head - & gt; next;
The head - & gt; Next=TMP;
}
}
Struct Stu * Max=(struct Stu *) malloc (sizeof (struct Stu));
Max - & gt; Business=0.0;
Struct Stu * p=head - & gt; next;
While (p)
{
If (p - & gt; Business & gt; Max - & gt; Business)
{
Max=p;
}
P=p - & gt; next;
}
Printf (" % s is the name of the tallest students in the divide, the student number is % s \ n ", Max - & gt; The name, Max - & gt; No);
return 0;
}

CodePudding user response:

 {
If (p - & gt; Business & gt; Max - & gt; Business)
{
Max=p;
}
P=p - & gt; next;
}

This memory leaks, you applied for space, the Max dynamic here then Max=p; The Max point to memory is I can't find it?

The
reference 3 floor 5250 response:
primary school the younger sister don't panic

 # include & lt; Stdio. H> 
#include
#include

Struct Stu
{
Char no [20].
Char name [10].
Float math;
Float here;
Float English;
Float business;
Struct Stu * next;
};

Int main (void)
{
The FILE * fp.
Fp=fopen (" student. TXT ", "r");
if (! Fp)
{
Printf (" file open failed ");
exit(0);
}
Struct Stu * head=(struct Stu *) malloc (sizeof (struct Stu));
Struct Stu * TMP;
The head - & gt; Next=NULL;
Char no [20].
Char name [10].
Float math;
Float here;
Float English;
Float business;
While (fscanf (fp, "% s \ \ t t % s, % f, % f, % f \ t \ \ t t % f", no, name, & amp; Math, & amp; Here, & amp; English, & amp; Business)!=(EOF)
{
TMP=(struct Stu *) malloc (sizeof (struct Stu));
TMP - & gt; Next=NULL;
If (TMP)
{
Strcpy (TMP - & gt; No, no);
Strcpy (TMP - & gt; The name, name);
TMP - & gt; Math=math;
TMP - & gt; Here=here;
TMP - & gt; English=English;
TMP - & gt; Business=business;
TMP - & gt; Next=head - & gt; next;
The head - & gt; Next=TMP;
}
}
Struct Stu * Max=(struct Stu *) malloc (sizeof (struct Stu));
Max - & gt; Business=0.0;
Struct Stu * p=head - & gt; next;
While (p)
{
If (p - & gt; Business & gt; Max - & gt; Business)
{
Max=p;
}
P=p - & gt; next;
}
Printf (" % s is the name of the tallest students in the divide, the student number is % s \ n ", Max - & gt; The name, Max - & gt; No);
return 0;
}

CodePudding user response:

 (brothers so much? ?? _???? )?

CodePudding user response:

 # include & lt; Stdio. H> 
#include
#include

Struct Stu
{
Char no [20].
Char name [10].
Float math;
Float here;
Float English;
Float business;
Struct Stu * next;
};

Int main (void)
{
The FILE * fp.
Fp=fopen (" student. TXT ", "r");
if (! Fp)
{
Printf (" file open failed ");
exit(0);
}
Struct Stu * head=(struct Stu *) malloc (sizeof (struct Stu));
Struct Stu * TMP;
//the head - & gt; Next=NULL;
Char no [20].
Char name [10].
Float math;
Float here;
Float English;
Float business;

The head - & gt; Next=NULL;
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related