c语言!!!程序设计:建立一个学生信息链表,包括学号,姓名,成绩.(实现添加,删除,查询,排序,平均) C语言编程 编写程序,建立一个学生数据链表,学生的数据包括学...
代码如下:
/*用c语言链表编写一个学生信息系统程序,要求输出学生的学号,姓名,性别,学号,姓名,成绩(实现添加,删除,查询,排序,平均)*/
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <stdlib.h>
using namespace std;
const int n=5;
/*
* nodeEntry : 节点数据类型
* nodeADT : 节点结构
* linkADT : 链表结构
*/
typedef struct Student
{
int num;
char name[30];
char sex;
float score1;//语文
float score2;//数学
float score3;//英语
//struct Student *next;
}Student;
typedef struct linkCDT {
nodeADT head;
}*linkADT;
/*
* InitLink : 初始化链表
* CreateNode : 创建节点
* AppendLink : 添加数据
*/
nodeADT CreateNode(Student entry) {
nodeADT p=(nodeADT)malloc(sizeof*p);
p->entry=entry,p->next=0;
return p;
}
/*
SortLink : 排序链表
//按学号排序
void SortLinkID(linkADT link) {
nodeADT pHead,pRear,p,tp;
if (!link) return;
for (pHead=link->head,pRear=0;pHead;pHead=pHead->next) {
for (tp=pHead,p=pHead->next;p;tp=p,p=p->next)
if (pHead->entry.num>=p->entry.num)
tp->next=p->next,p->next=pHead,pHead=p,p=tp;
if (!pRear) link->head=pHead;
else pRear->next=pHead;
pRear=pHead;
}
//按英语成绩排序
void SortLinkEnglish(linkADT link) {
nodeADT pHead,pRear,p,tp;
if (!link) return;
for (pHead=link->head,pRear=0;pHead;pHead=pHead->next) {
for (tp=pHead,p=pHead->next;p;tp=p,p=p->next)
if (pHead->entry.score3>=p->entry.score3)
tp->next=p->next,p->next=pHead,pHead=p,p=tp;
if (!pRear) link->head=pHead;
else pRear->next=pHead;
pRear=pHead;
}
}
//按姓名的字典序进行排序
void SortLinkName(linkADT link) {
nodeADT pHead,pRear,p,tp;
if (!link) return;
for (pHead=link->head,pRear=0;pHead;pHead=pHead->next) {
for (tp=pHead,p=pHead->next;p;tp=p,p=p->next)
if (pHead->entry.name[0]>=p->entry.name[0])
tp->next=p->next,p->next=pHead,pHead=p,p=tp;
if (!pRear) link->head=pHead;
else pRear->next=pHead;
pRear=pHead;
}
}
//按姓名的长度进行排序
void SortLinkNameLength(linkADT link) {
nodeADT pHead,pRear,p,tp;
if (!link) return;
for (pHead=link->head,pRear=0;pHead;pHead=pHead->next) {
for (tp=pHead,p=pHead->next;p;tp=p,p=p->next)
if (strlen(pHead->entry.name)>=strlen(p->entry.name))
tp->next=p->next,p->next=pHead,pHead=p,p=tp;
if (!pRear) link->head=pHead;
else pRear->next=pHead;
pRear=pHead;
}
循环链表是与单链表一样
是一种链式的存储结构,所不同的是,循环链表的最后一个结点的指针是指向该循环链表的第一个结点或者表头结点,从而构成一个环形的链。
循环链表的运算与单链表的运算基本一致。所不同的有以下几点:
1、在建立一个循环链表时,必须使其最后一个结点的指针指向表头结点,而不是象单链表那样置为NULL。此种情况还使用于在最后一个结点后插入一个新的结点。
2、在判断是否到表尾时,是判断该结点链域的值是否是表头结点,当链域值等于表头指针时,说明已到表尾。而非象单链表那样判断链域值是否为NULL。
以上内容参考:百度百科-链表
代码如下:
/*用c语言链表编写一个学生信息系统程序,要求输出学生的学号,姓名,性别,
学号,姓名,成绩.(实现添加,删除,查询,排序,平均)*/
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <stdlib.h>
using namespace std;
const int n=5;
/*
* nodeEntry : 节点数据类型
* nodeADT : 节点结构
* linkADT : 链表结构
*/
typedef struct Student
{
int num;
char name[30];
char sex;
float score1;//语文
float score2;//数学
float score3;//英语
//struct Student *next;
}Student;
typedef struct nodeCDT {
Student entry;
struct nodeCDT *next;
}*nodeADT;
typedef struct linkCDT {
nodeADT head;
}*linkADT;
/*
* InitLink : 初始化链表
* CreateNode : 创建节点
* AppendLink : 添加数据
*/
void InitLink(linkADT *link) {
*link=(linkADT)malloc(sizeof*(*link));
(*link)->head=0;
}
nodeADT CreateNode(Student entry) {
nodeADT p=(nodeADT)malloc(sizeof*p);
p->entry=entry,p->next=0;
return p;
}
void AppendLink(linkADT *link,Student entry) {
nodeADT newNode=CreateNode(entry),p;
if (!*link) InitLink(link);
if (!(*link)->head) (*link)->head=newNode;
else {
for (p=(*link)->head;p->next;p=p->next);
p->next=newNode;
}
}
/*
* SortLink : 排序链表
* -------------------
* 通过移动每个节点的指针来完成排序
*/
//按学号排序
void SortLinkID(linkADT link) {
nodeADT pHead,pRear,p,tp;
if (!link) return;
for (pHead=link->head,pRear=0;pHead;pHead=pHead->next) {
for (tp=pHead,p=pHead->next;p;tp=p,p=p->next)
if (pHead->entry.num>=p->entry.num)
tp->next=p->next,p->next=pHead,pHead=p,p=tp;
if (!pRear) link->head=pHead;
else pRear->next=pHead;
pRear=pHead;
}
}
//按语文成绩排序
void SortLinkChinese(linkADT link) {
nodeADT pHead,pRear,p,tp;
if (!link) return;
for (pHead=link->head,pRear=0;pHead;pHead=pHead->next) {
for (tp=pHead,p=pHead->next;p;tp=p,p=p->next)
if (pHead->entry.score1>=p->entry.score1)
tp->next=p->next,p->next=pHead,pHead=p,p=tp;
if (!pRear) link->head=pHead;
else pRear->next=pHead;
pRear=pHead;
}
}
//按数学成绩排序
void SortLinkMath(linkADT link) {
nodeADT pHead,pRear,p,tp;
if (!link) return;
for (pHead=link->head,pRear=0;pHead;pHead=pHead->next) {
for (tp=pHead,p=pHead->next;p;tp=p,p=p->next)
if (pHead->entry.score2>=p->entry.score2)
tp->next=p->next,p->next=pHead,pHead=p,p=tp;
if (!pRear) link->head=pHead;
else pRear->next=pHead;
pRear=pHead;
}
}
//按英语成绩排序
void SortLinkEnglish(linkADT link) {
nodeADT pHead,pRear,p,tp;
if (!link) return;
for (pHead=link->head,pRear=0;pHead;pHead=pHead->next) {
for (tp=pHead,p=pHead->next;p;tp=p,p=p->next)
if (pHead->entry.score3>=p->entry.score3)
tp->next=p->next,p->next=pHead,pHead=p,p=tp;
if (!pRear) link->head=pHead;
else pRear->next=pHead;
pRear=pHead;
}
}
//按姓名的字典序进行排序
void SortLinkName(linkADT link) {
nodeADT pHead,pRear,p,tp;
if (!link) return;
for (pHead=link->head,pRear=0;pHead;pHead=pHead->next) {
for (tp=pHead,p=pHead->next;p;tp=p,p=p->next)
if (pHead->entry.name[0]>=p->entry.name[0])
tp->next=p->next,p->next=pHead,pHead=p,p=tp;
if (!pRear) link->head=pHead;
else pRear->next=pHead;
pRear=pHead;
}
}
//按姓名的长度进行排序
void SortLinkNameLength(linkADT link) {
nodeADT pHead,pRear,p,tp;
if (!link) return;
for (pHead=link->head,pRear=0;pHead;pHead=pHead->next) {
for (tp=pHead,p=pHead->next;p;tp=p,p=p->next)
if (strlen(pHead->entry.name)>=strlen(p->entry.name))
tp->next=p->next,p->next=pHead,pHead=p,p=tp;
if (!pRear) link->head=pHead;
else pRear->next=pHead;
pRear=pHead;
}
}
// PrintLink : 打印链表
void PrintLink(linkADT link) {
nodeADT p=link->head;
cout<<"学号"<<" "<<"姓名"<<""<<"性别"<<""
<<"语文"<<""<<"数学"<<""<<"英语"<<endl;
for (;p;p!=NULL,p=p->next){
cout<<p->entry.num<<" "<<p->entry.name<<""<<p->entry.sex<<""
<<p->entry.score1<<""<<p->entry.score2<<""<<p->entry.score3<<endl;
}
printf("
");
}
/* 测试 */
int main() {
linkADT link=0;
Student stu[n]={{1002,"Gao Min",'M',80,80,80},{1008,"Wen LR",'M',79,80,70},
{1000,"Wan Huang",'F',72,94,87},{1006,"Zhang Xin",'F',90,90,90},
{1001,"Liu qing",'M',89,90,92}};
int i;
for (i=0;i<n;AppendLink(&link,*(stu+i++)));
cout<<"请选择:"<<endl;
cout<<"1、按照学号升序排序"<<endl;
cout<<"2、按照姓名字符长度升序排序"<<endl;
cout<<"3、按照姓名字典序升序排序"<<endl;
cout<<"4、按照语文成绩升序排序"<<endl;
cout<<"5、按照数学成绩升序排序"<<endl;
cout<<"6、按照英语升序排序"<<endl;
//cout<<"7、未排序数据"<<endl;
cout<<"0、退出"<<endl;
//cout<<"未排序数据:"<<endl;
//PrintLink(link);
int n;
while(~scanf("%d",&n)){
if(n==0) break;
else if(n==1){
cout<<"按照学号升序排序:"<<endl;
SortLinkID(link);
PrintLink(link);
}
else if(n==2){
cout<<"按照姓名字符长度升序排序:"<<endl;
SortLinkNameLength(link);
PrintLink(link);
}
else if(n==3){
cout<<"按照姓名字典序升序排序:"<<endl;
SortLinkName(link);
PrintLink(link);
}
else if(n==4){
cout<<"按照语文成绩升序排序:"<<endl;
SortLinkChinese(link);
PrintLink(link);
}
else if(n==5){
cout<<"按照数学成绩升序排序:"<<endl;
SortLinkMath(link);
PrintLink(link);
}
else if(n==6){
cout<<"按照英语升序排序:"<<endl;
SortLinkEnglish(link);
PrintLink(link);
}
else cout<<"输入错误,请重新输入!"<<endl;
}
return 0;
}
拓展资料:
链表是一种物理存储单元上非连续、非顺序的存储结构,数据元素的逻辑顺序是通过链表中的指针链接次序实现的。链表由一系列结点(链表中每一个元素称为结点)组成,结点可以在运行时动态生成。每个结点包括两个部分:一个是存储数据元素的数据域,另一个是存储下一个结点地址的指针域。 相比于线性表顺序结构,操作复杂。由于不必须按顺序存储,链表在插入的时候可以达到O(1)的复杂度,比另一种线性表顺序表快得多,但是查找一个节点或者访问特定编号的节点则需要O(n)的时间,而线性表和顺序表相应的时间复杂度分别是O(logn)和O(1)。
使用链表结构可以克服数组链表需要预先知道数据大小的缺点,链表结构可以充分利用计算机内存空间,实现灵活的内存动态管理。但是链表失去了数组随机读取的优点,同时链表由于增加了结点的指针域,空间开销比较大。链表最明显的好处就是,常规数组排列关联项目的方式可能不同于这些数据项目在记忆体或磁盘上顺序,数据的存取往往要在不同的排列顺序中转换。链表允许插入和移除表上任意位置上的节点,但是不允许随机存取。链表有很多种不同的类型:单向链表,双向链表以及循环链表。链表可以在多种编程语言中实现。像Lisp和Scheme这样的语言的内建数据类型中就包含了链表的存取和操作。程序语言或面向对象语言,如C,C++和Java依靠易变工具来生成链表。
1、更多交流可参考我空间主页有关文章。
2、#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
/*定义结构体*/
struct student
{
int num;
float score;
struct student *next;
};
/*创建一个只有头结点的空链表*/
struct student *create_head()
{
struct student *head;
head=(struct student*)malloc(sizeof (struct student) );
if(head==NULL) //小心别漏这个
{
printf("申请头结点失败!\n");
return NULL;
}
head->next=NULL;
return head;
}
/*将s指向的结点插入链表,使链表保持升序,并返回头结点*/
struct student *insert(struct student *head,struct student *s)
{
struct student *p=head;
while(p->next!=NULL&&s->score>p->next->score)//特别注意&&左右不能写反,若s最大,最后p->next=NULL,p->next->score运行出错
p=p->next;
if(p->next==NULL) //s->score最大的情况 //其实两种情况可以并在一块写
{
p->next=s; //连接结点
s->next=NULL; //p->next就等于NULL
}
else
{
p->next=s; //连接结点
s->next=p->next;
}
return head ;
}
/*查找符合条件的结点,并返回指向该结点的指针*/
struct student *search(struct student *head)
{
struct student *p=head->next;
int num;
printf("请输入要查找学生的学号:\n");
scanf("%d",&num);
while(p!=NULL&&p->num!=num) //特别注意两条件不能写反,若写反最后p指向NULL时p->num找不到 运行出错
p=p->next;
if(p==NULL) //特别注意两个if不能调换,若调换最后p指向NULL时p->num运行出错
{
printf("找不到符合条件的结点!!!");
return NULL; //查找不到返回空指针
}
if(p->num==num)
{
printf("找到符合条件的结点\n该结点为%d\t%f",p->num,p->score);
return p; //返回查找到的指针
}
}
/*输出链表各结点的值,也称对链表的遍历*/
void print(struct student *head)
{
struct student *p;
printf(" 链表如下: \n");
p=head->next;
while(p!=NULL)
{
printf("%d\t%.1f\n",p->num,p->score);
p=p->next;
}
}
/*释放链表*/
void free_list(struct student *head)
{
struct student *p=head ;
printf("释放链表:\n");
while(p!=NULL)
{
head=head->next;
free(p);
p=head;
}
printf("释放链表成功!\n");
}
/*删除链表中值为num的结点,并返回链表的首指针*/
struct student *delete_note(struct student *head,int num_x)
{
struct student *p1=head->next , *p2=head ;
while(p1!=NULL&&p1->num!=num_x) //特别注意&&左右条件不能调换,若调换如果p1指向NULL时p1->num运行出错
{
p2=p1;
p1=p1->next;
}
if(p1==NULL) //特别注意两个if不能调换,若调换如果p1指向NULL时,p1->num运行出错
printf("找不到符合删除要求的结点!!!\n");
if(p1->num==num_x)
{
p2->next=p1->next;
free(p1);
printf("结点删除成功!\n");
}
return head;
}
/*完整的有头结点链表操作程序*/
void main()
{
struct student *p , *head ;
char c;
int num ;
float score ;
printf("有头结点链表操作程序:\n");
head=create_head();
while(1)
{
printf("I:插入结点(自动升序) P:输出链表 S:查找结点 D:删除结点 E:释放链表并退出程序! ");
c=getch();
switch(c)
{
case'I':
printf("请分别输入要插入学生的学号和分数:\n");
scanf("%d%f",&num,&score);
p=(struct student*)malloc( sizeof(struct student) );
if(p==NULL)
{
printf("申请该结点失败!!!\n");
exit (0) ;
}
p->num=num; p->score=score; //给p赋值
insert(head,p);
printf("插入成功!\n");
break;
case'P':
print(head);
break;
case'S':
search(head);
break;
case'D':
printf("请输入要删除的学生的学号:\n");
scanf("%d",&num);
delete_note(head,num);
break;
case'E':
free_list(head);
exit (0);
}
}
}
#include<iostream>
using namespace std;
struct stu{
char name[20];
int num;
int age;
char sex;
int grade;
struct stu *next;
};
struct stu *mythis,*mynew;
void newrecord(struct stu *head)
{
mythis=head->next;
while(mythis!=NULL)
mythis=mythis->next;
mynew=(struct stu *)malloc(sizeof(struct stu));
cin>>mynew->name>>mynew->num>>mynew->age>>mynew->sex>>mynew->grade;
mynew->next=NULL;
if(mythis==NULL)
{
mythis=(struct stu *)malloc(sizeof(struct stu));
mythis=mynew;
}
}
void listall(stu *head)
{
mythis=head->next;
while(mythis!=NULL)
{
cout<<mythis->name<<mythis->num<<mythis->age<<mythis->sex<<mythis->grade;
mythis=mythis->next;
}
}
int main()
{
char decide;
struct stu *head;
head=(struct stu *)malloc(sizeof(struct stu));
head->next=NULL;
while(1)
{
cout<<"Please input decide:"<<endl;
cin>>decide;
if(decide=='n')
newrecord(head);
else
if(decide=='1')
listall(head);
else
return 0;
}
}
拓展资料
C语言是一门通用计算机编程语言,应用广泛。C语言的设计目标是提供一种能以简易的方式编译、处理低级存储器、产生少量的机器码以及不需要任何运行环境支持便能运行的编程语言。
尽管C语言提供了许多低级处理的功能,但仍然保持着良好跨平台的特性,以一个标准规格写出的C语言程序可在许多电脑平台上进行编译,甚至包含一些嵌入式处理器(单片机或称MCU)以及超级电脑等作业平台。
二十世纪八十年代,为了避免各开发厂商用的C语言语法产生差异,由美国国家标准局为C语言制定了一套完整的美国国家标准语法,称为ANSI C,作为C语言最初的标准。目前2011年12月8日,国际标准化组织(ISO)和国际电工委员会(IEC)发布的C11标准是C语言的第三个官方标准,也是C语言的最新标准,该标准更好的支持了汉字函数名和汉字标识符,一定程度上实现了汉字编程。
链表制作教程
输入样例:
1 zhang 78
2 wang 80
3 li 75
4 zhao 85
0
输出样例:
1 zhang 78
2 wang 80
3 li 75
4 zhao 85
ANSWER
void input()
{
struct stud_node *q;
q=(struct stud_node *)malloc(sizeof(struct stud_node));
scanf("%d", &q->num);
while(q->num != 0)
{
scanf("%s %d", q->name, &q->score);
if(head == NULL)
{
head = q;
head->next = NULL;
}
if(tail != NULL)
{
tail->next = q;
}
tail = q;
tail->next = NULL;
q=(struct stud_node *)malloc(sizeof(struct stud_node));
scanf("%d", &q->num);
}
}
代码运行
C语言编程 编写程序,建立一个学生数据链表,学生的数据包括学号、姓名、成绩。~
#include
#include
#define NULL 0
struct stud
{
int no;
char name[12];
int age;
struct stud*next;
};
#define LEN sizeof(struct stud)
struct stud*creat(void)
{
struct stud*p1,*p2,*head;
int n=0;
p1=(struct stud*)malloc(LEN);
scanf("%d%s%d",&p1->no,p1->name,&p1->age);
while(p1->no>0){
n++;
if(n==1){head=p1;p2=p1;}
else{p2->next=p1;p2=p1;}
p1=(struct stud*)malloc(LEN);
scanf("%d",&p1->no);
if(p1->no==0)break;
scanf("%s%d",p1->name,&p1->age);
}
p2->next=NULL;
return head;
}
void main()
{
struct stud*del(struct stud*head,int no);
int num;
struct stud*p,*p0;
p0=creat();
scanf("%d",&num);
p=del(p0,num);
print(p);
}
struct stud*del(struct stud*head,int num)
{
struct stud *p1,*p2;
p1=head;
while(p1->next!=NULL){
if(p1->no==num) break;
p2=p1;
p1=p1->next;
}
if(p1==head){
p1->next=head;
}
else {
p2->next=p1->next;
}
return head;
}
数据描述:学号 姓名 班级 高数 英语 总分
程序完成功能:
(1) 浏览数据 (2) 增加数据 (3) 修改数据
(4) 查询数据(按姓名,按总分) (5) 退出
*/
#include
#include
#include
using namespace std;
class student
{
public:
student(int , string ,int ,int ,int );
string getName(){return _name;};
int getID(){return _ID;};
void setID(int i){_ID=i;};
void setName(string);
void setClass(int c){_class=c;};
void setMath(int m){_math=m;_total=_math+_english;};
void setEnglish(int e){_english=e;_total=_math+_english;}
void print();
static int _stNum;
private:
int _ID;
string _name;
int _class;
int _math;
int _english;
int _total;
};
int student::_stNum=0;
student::student(int id, string name, int iclass, int ma, int en)
{
_ID=id;
_name=name;
_class=iclass;
_math=ma;
_english=en;
_total=_math+_english;
_stNum++;
};
void student::setName(string s)
{
_name=s;
};
void student::print()
{
cout<<_ID
<<""<< _name
<<""<<_class
<<""<<_math
<<""<<_english
<<""<<_total <<endl;
}
void printMenu(void);
void printHead(void);
void printTail(int);
void main()
{
int tmp_ID;
string tmp_name;
int tmp_class;
int tmp_math;
int tmp_english;
int order=0;
vector stvec;
printMenu();
cin>>order;
while(order!=5)
{
switch(order)
{
case 1:
if (stvec.size()==0)
{
coutNo data in the system!"<<endl<<endl;
printMenu();
cin>>order;
break;
}
else
{
vector::iterator iter=stvec.begin();
vector::iterator iter_end=stvec.end();
printHead();
for(;iter!=iter_end;iter++)
{
(*iter).print();
}
printTail(stvec.size());
printMenu();
cin>>order;
break;
}
case 2:
coutID:";
cin>>tmp_ID;
coutName:";
cin>>tmp_name;
coutClass:";
cin>>tmp_class;
coutMark of Math:";
cin>>tmp_math;
coutMark of English:";
cin>>tmp_english;
stvec.push_back(student(tmp_ID,tmp_name,tmp_class,tmp_math,tmp_english));
printMenu();
cin>>order;
break;
case 3:
{
string search_name;
bool isFind=false;
coutName:";
cin>>search_name;
vector::iterator iter=stvec.begin();
vector::iterator iter_end=stvec.end();
for(;iter!=iter_end;iter++)
{
if( (*iter).getName()==search_name )
{
isFind=true;
coutID:";
cin>>tmp_ID;
coutName:";
cin>>tmp_name;
coutClass:";
cin>>tmp_class;
coutMark of Math:";
cin>>tmp_math;
coutMark of English:";
cin>>tmp_english;
(*iter).setID(tmp_ID);
(*iter).setName(tmp_name);
(*iter).setClass(tmp_class);
(*iter).setMath(tmp_math);
(*iter).setEnglish(tmp_english);
}
}
if(!isFind)
{
cout<<"There no student named "<<search_name<<endl;
}
printMenu();
cin>>order;
break;
}
case 4:
string search_name;
int search_ID;
int name_ID=0;
bool isFind=false;
cout<<"-----------"<<endl;
cout<<"1.Name:"<<endl;
cout<<"2.ID:"<<endl;
cout<<"-----------"<<endl;
cin>>name_ID;
if (name_ID==1)
{
coutname:"<<endl;
cin>>search_name;
vector::iterator iter=stvec.begin();
vector::iterator iter_end=stvec.end();
for(;iter!=iter_end;iter++)
{
if( (*iter).getName()==search_name )
{
if(!isFind)
{
cout<<endl<<"Your search:"<<endl;
printHead();
}
(*iter).print();
isFind=true;
}
}
if(isFind){ cout<<"-------------------------------------------------"<<endl;}
if(!isFind)
{
cout<<"There no student named :"<<search_name<<endl;
}
printMenu();
cin>>order;
break;
}
if (name_ID==2)
{
coutID:"<<endl;
cin>>search_ID;
vector::iterator iter=stvec.begin();
vector::iterator iter_end=stvec.end();
for(;iter!=iter_end;iter++)
{
if( (*iter).getID()==search_ID)
{
if(!isFind)
{cout<<endl<<"Your search:"<<endl; printHead();}
(*iter).print();
isFind=true;
}
}
if(isFind){ cout<<"-------------------------------------------------"<<endl;}
if(!isFind)
{
cout<<"There no student ID :"<<search_name<<endl;
}
printMenu();
cin>>order;
break;
}
}
}
}
void printMenu(void)
{
cout<<endl<<"*************Make**your**choice***************"<<endl;
cout<<"1. View the data"<<endl;
cout<<"2. ADD the data"<<endl;
cout<<"3. Update the data"<<endl;
cout<<"4. Search the data"<<endl;
cout<<"5. Quit"<<endl;
cout<<"********************************************"<<endl<<endl;
}
void printHead(void)
{
cout<<"-------------------------------------------------"<<endl;
cout<<"IDNameClassMathEnglishTotal"<<endl;
}
void printTail(int i)
{
cout<<"There are total ";
if (i ==1)
{cout<< i<<" student"<<endl;}
else if(i >1)
{cout<<i<<" students"<<endl;}
cout<<"-------------------------------------------------"<<endl;
}
相关要点总结:
15374292044:用C语言设计一个学生成绩管理系统
涂馨答:include <stdio.h>#include <string.h> include <stdlib.h>#define MAX 1000/*定义学生成绩信息结构*/struct stu{ char id[8];char name[8];
15374292044:C语言程序设计 学生信息管理系统
涂馨答:【功能要求】(1)学生信息包括:学号,姓名,性别,出生(年,月,日),三门课成绩和总分(数学,英语,C语言,总分)。(2)数据格式:测试数据,以文件方式提供,studf.txt,数据文件自己建... 【功能要求】(1)学生信息包括:学号,姓名,性别,出生(年,月,日),三门课成绩和总分( 数学, 英语, C语言, 总分)。(2)数据格...
15374292044:用C语言设计一个学生信息查询系统程序
涂馨答:1、首先创建一个c语言项目。然后右键头文件,创建一个Stu的头文件。2、编写头文件的代码。再将数据结构的增删改查和结构体写入头文件。3、在源文件中创建main源文件和Stu源文件。再main文件中写入int mian()代码。4、然后在mian主函数中,写入while语句无限循环。再写入Init函数。5、在Stu源文件的...
15374292044:C语言设计一个学生学籍管理系统,要求文件形式保存,且用到链表
涂馨答:float score1; float score2; float score3; char filename[] = "D:\\编程学习\\编程实践\\c语言课程设计1 学生信息管理\\data.txt"; //文件名,此处为简化编程,采用固定地址名称,未作输入 FILE *fp; pstu head,ptr; //创建带表头结点的空单链表head,用来存放载入信息 head = (pstu)malloc(SIZE)...
15374292044:c语言程序:某班有10名同学,建立学生结构体类型,包括学号,姓名,3门课程...
涂馨答:include <stdio.h> include"string.h"include <stdlib.h> define N 100000 struct st{ char a[15];char b[20];int x,y,z;};int fun1(int *x,int *y){ int t;t=*x;x=*y;y=t;} int fun2(char *x,char *y){ char *t;strcpy(t,x);strcpy(x,y);strcpy(y,t);} int ...
15374292044:用c语言链表编写一个学生信息系统程序,要求输出学生的学号,姓名,性别...
涂馨答:/ 用c语言链表编写一个学生信息系统程序,要求输出学生的学号,姓名,性别,还有三门课比如语,数,外的成绩 / //FileName: stuinfo.c include <stdio.h> include <stdlib.h> include <string.h> define SERIALLEN 20 define COURSENUM 3 typedef struct { char course[SERIALLEN];float score;}...
15374292044:用c语言程序设计一个学生通讯录系统
涂馨答:用c语言程序设计一个学生通讯录系统 10 问题描述:通讯录管理系统主要管理用户通讯录的基本信息。在系统中,每个用户是一条记录,包括姓名、电话号码、通讯地址。系统要对一个有N个用户的通讯录统一进行管理。包括了用户信息... 问题描述:通讯录管理系统主要管理用户通讯录的基本信息。在系统中,每个用户是一条记录,...
15374292044:用C语言写一个 小学生口算出题系统
涂馨答:一、设计的流程:1. 主界面设计,选择练习或测试,按ESC结束程序。 2. 题型选择界面设计,选择加、减、乘、除或混合运算,按ESC返回主界面。 3. 系统随机出题,运算数及结果均在100以内,乘、除法应能整除,显示算式。 4. 练习时,系统随机出题,键入结果,正确和错误均有提示,出错时允许再输入...
15374292044:c语言程序设计编程题目:请 :编写完成对学生相关信息的要求:1.定义一...
涂馨答:for(int j = i+1 ; j < n; j++){ if(stu[i].total < stu[j].total){ stud = stu[i];stu[i] = stu[j];stu[j] = stud;} } } int main( ){ student stu[STU_NUM]; /*创建结构体数组中有10个元素,分别用来保存这10个人的相关信息。*/ /*输入这十个学生的相关信息*/ ...
15374292044:C语言程序设计 学生成绩管理信息系统
涂馨答:C语言程序设计 学生成绩管理信息系统 5 问题描述:通过开发一个学生成绩管理信息系统,掌握与数组有关的算法、函数的调用、结构体类型变量的定义和使用;文件打开、关闭、读、写等文件操作函数的使用,提高实际运用能力。基... 问题描述:通过开发一个学生成绩管理信息系统,掌握与数组有关的算法、函数的调用、结构体类型...