69,382
社区成员
发帖
与我相关
我的任务
分享
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
struct stud
{
char Name[20];
float Score;
struct stud*next;
};
typedef struct stud Student;
Student* Create();
Student* Insert(Student*head);
void Display_Main_Menu();
int menu_select();
int Continue();
int main(int argc,char*argv[])
{
Display_Main_Menu();
for(;;)
{
switch(menu_select())
{
case 1:
printf("Execution of \"Creat List\"\n");
Create();
break;
default:
printf("error!please input 1\n");
};
}
return 0;
}
int menu_select()
{
int SelectedNumber;
printf("please input the number(from 0 to 7) and \'Enter\':");
scanf("%d",&SelectedNumber);
return SelectedNumber;
};
void Display_Main_Menu()
{
printf("1. Creat List\n");
printf("2. Display All Record\n");
printf("3. Insert a Record\n");
printf("4. Delete a Record\n");
printf("5. Query\n");
printf("6. Add Records from a Text File\n");
printf("7. Write to a Text File\n");
printf("0. Quit\n");
printf("Give your choice(0-7): ");
};
int Continue()
{
char choice;
printf("continue to input? press \'y\' or \'n\': ");
scanf("%c",&choice);
if(choice=='y')
return 1;
}
Student* Insert(Student*head)
{
Student* NewData=(struct Stud*)malloc(sizeof(struct stud));
printf("please input a name and \'Enter\': ");
scanf("%s",NewData->Name);
printf("please input the score and \'Enter\': ");
scanf("%d",&(NewData->Score));
NewData->next=NULL;
if(head==NULL)
{
head=NewData;
return head;
}
Student *CurrentData=head;
while(CurrentData->next!=NULL)
{
CurrentData=CurrentData->next;
};
CurrentData->next=NewData;
}
Student* Create()
{
static struct Student *head=NULL;
do
{
Insert(head);
printf("Insert a piece of data successfully\n");
}
while(Continue()==1);
return head;
}
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
struct stud
{
char Name[20];
float Score;
struct stud*next;
};
typedef struct stud Student;
Student* Create();
Student* Insert(Student*head);
void Display_Main_Menu();
int menu_select();
int Continue();
int main(int argc,char*argv[])
{
Display_Main_Menu();
for(;;)
{
switch(menu_select())
{
case 1:
printf("Execution of \"Creat List\"\n");
Create();
break;
default:
printf("error!please input 0-5\n");
};
}
return 0;
}
int menu_select()
{
int SelectedNumber;
printf("please input the number(from 0 to 7) and \'Enter\':");
scanf("%d",&SelectedNumber);
return SelectedNumber;
};
void Display_Main_Menu()
{
printf("1. Creat List\n");
printf("2. Display All Record\n");
printf("3. Insert a Record\n");
printf("4. Delete a Record\n");
printf("5. Query\n");
printf("6. Add Records from a Text File\n");
printf("7. Write to a Text File\n");
printf("0. Quit\n");
printf("Give your choice(0-7): ");
};
int Continue()
{
char choice;
printf("continue to input? press \'y\' or \'n\': ");
scanf("%c",&choice);
if(choice=='y')
return 1;
}
Student* Insert(Student*head)
{
Student* NewData=(Student*)malloc(sizeof(Student));
printf("please input a name and \'Enter\': ");
scanf("%s",NewData->Name);
printf("please input the score and \'Enter\': ");
scanf("%d",&(NewData->Score));
NewData->next=NULL;
if(head==NULL)
{
head=NewData;
return head;
}
Student *CurrentData=head;
while(CurrentData->next!=NULL)
{
CurrentData=CurrentData->next;
};
CurrentData->next=NewData;
}
Student* Create()
{
static Student *head=NULL;
do
{
Insert(head);
printf("Insert a piece of data successfully\n");
}
while(Continue()==1);
return head;
}
Student* Insert(Student*head)
{
Student* NewData=(Student*)malloc(sizeof(Student));//mark
printf("please input a name and \'Enter\': ");
scanf("%s",NewData->Name);
printf("please input the score and \'Enter\': ");
scanf("%d",&(NewData->Score));
NewData->next=NULL;
if(head==NULL)
{
head=NewData;
return head;
}
Student *CurrentData=head;
while(CurrentData->next!=NULL)
{
CurrentData=CurrentData->next;
};
CurrentData->next=NewData;
}
Student* Create()
{
static Student *head=NULL;//mark
do
{
Insert(head);
printf("Insert a piece of data successfully\n");
}
while(Continue()==1);
return head;
}
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
struct stud
{
char Name[20];
float Score;
struct stud*next;
};
typedef struct stud Student;
Student* Create();
Student* Insert(Student*head);
void Display_Main_Menu();
int menu_select();
int Continue();
int main(int argc,char*argv[])
{
Display_Main_Menu();
for(;;)
{
switch(menu_select())
{
case 1:
printf("Execution of \"Creat List\"\n");
Create();
break;
default:
printf("error!please input 0-5\n");
};
}
return 0;
}
int menu_select()
{
int SelectedNumber;
scanf("%d",&SelectedNumber);
return SelectedNumber;
};
void Display_Main_Menu()
{
printf("1. Creat List\n");
printf("2. Display All Record\n");
printf("3. Insert a Record\n");
printf("4. Delete a Record\n");
printf("5. Query\n");
printf("6. Add Records from a Text File\n");
printf("7. Write to a Text File\n");
printf("0. Quit\n");
printf("Give your choice(0-7): ");
};
int Continue()
{
char choice;
printf("continue to input? press \'y\' or \'n\': ");
scanf("%c",&choice);
if(choice=='y')
return 1;
}
Student* Insert(Student*head)
{
Student* NewData=(Student*)malloc(sizeof(Student));
Student *CurrentData=head;
printf("please input a name and \'Enter\': ");
scanf("%s",NewData->Name);
printf("please input the score and \'Enter\': ");
scanf("%d",&(NewData->Score));
NewData->next=NULL;
if(head==NULL)
{
head=NewData;
return head;
}
while(CurrentData->next!=NULL)
{
CurrentData=CurrentData->next;
};
CurrentData->next=NewData;
return head;
}
Student* Create()
{
static Student *head=NULL;
do
{
Insert(head);
printf("Insert a piece of data successfully\n");
}
while(Continue()==1);
return head;
}