怎么用c 用c语言编写心形动态心

用c语言编写一个字幕滚动程序?_百度知道
用c语言编写一个字幕滚动程序?
我有更好的答案
);i;\n&int&main(){ char&str[100]&=&nbsp.h&#include&&strlen(str);,str[j]);
Sleep(100);
printf(&%c&i++) {
system(&cls&HELLO&WORLD!&GOOD&BYE!&;j&strlen(str);j++)
printf(&quot,j;&
for(j=i;); for(i=0;i&lt.h&#include&&windows.h& int&&quot以下代码实现字符从右到左循环滚动.C语言控制台程序#include&nbsp
软件工程师
你好!是想怎么滚动,在dos 下吗
为您推荐:
其他类似问题
您可能关注的内容
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。用C语言编写_百度知道
用C语言编写
用静态数组(或链表)结构实现学生档案管理,数组的每一个元素是结构体类型
通过这个例子了解数组库管理的基本功能,重点掌握数组元素为结构体的应用,数组做函数参数,文件读写,自定义函数等知识。主要实现:建立学生信息库,显示,查找,删除,插入,保存...
我有更好的答案
The highest : %s .h& #define N 10 typedef struct ss { char num[10];N.s&#47.num,{&A02&quot,87};A01&;N; } main ( ) { STU a[N]={ {&quot,l;A10&,&l); } STU;,89},{&A03&, STU *min) {
float x=0;n&; float fun( STU a[]; for(i=1;i&lt, %d&#92, STU * } , a[i].num,a[i];A06&,90}, {& *max=*min=a[0],{&A05&quot, %d&#92, h,l;
for ( i=0; i& N,81};,61},{&,77},{&i++) { if(a[i].s&gt, {&quot.s); avg=fun (),71} };s) { *max=a[i]; } if(a[i];max-&gt, &h; printf (&The lowest : %s ,66}.s&min-&s) { *min=a[i],{&A08&quot,h; } x=x+a[i], h.s), {& printf (&TA04&;A07&#include & printf (&***** THE RESULT *****&#92,80};n&:%f\n&quot.h& #include & i++ )printf(&No = %s Mark = %d\n&,avg);stdio, l.s); float avg=0; printf(&***** The original data *****\n&quot.n&); printf (&A09&,79}
采纳率:23%
/*查找*/***************MENU***************&
/#include &mem.h&
case 6:head=load();
/*链表定义头指针*/
head=init():computer(head);
}}/*菜单函数,返回值为整数*/menu_select(){
char *menu[]={&
case 3:print(head);
/*显示全部记录*/*值不同,执行的函数不同,break 不能省略*/
case 0;* 显示所有记录*/
switch(menu_select())
/*调用主菜单函数;
/*I/O函数*/*定义常数*/typedef struct z1
/*排序*/STUDENT *index(STUDENT *h);break.h&
/*字符操作函数*/*计算总分和均分*/int menu_select();
case 4:search(head);*读入记录*/void computer(STUDENT *h);
/ 2. Delete a record from list&;
/void save(STUDENT *h);
& 1; }STUDENT;*如菜单返回值为14程序结束*/#include &alloc.h&
/*查找记录*&#47,
/*动态地址分配函数*/#define N 3
/*复制文件*&#47:head=index(head);
/*定义数据结构*/{
char no[11];
char name[15]:exit(0);/******主函数开始*******/
case 11:head=sort(head);
case 8:head=insert(head); /*插入记录*//*以下是函数原型*/STUDENT
int score[N];,
/*定义菜单字符串数组*/
/*读文件*/
case 7;*保存*/STUDENT *load();
/STUDENT *insert(STUDENT *h);
struct z1 *
case 1:head=create(); /*创建链表*/#include &#include &*索引*/
case 13:total(head);
/*分类合计*/*删除记录*/void print(STUDENT *h);
case 5:save(head);break. init list&void search(STUDENT *h). Enter list&;*计算总分和均分*/void total(STUDENT *h);
/*分类合计*/
case 2:head=delete(head); /*删除记录*/*清屏*/
/*菜单函数*/*插入记录*/void append();
case 9:copy();main(){*执行初始化*/*追加记录*/void copy();
/*字符串函数*/#include &)
/*无限循环*/STUDENT *delete(STUDENT *h):append();
/*追加记录*&#47:head=init();
/*保存文件*/
case 10.h&
/*其它说明*/*初始化*&#47&#47.h&
/*屏幕操作函数*&#47,
/*从表中删除记录*/
& 3. print list &,
/*显示单链表中所有记录*/
& 4. Search record on name&,
/*按照姓名查找记录*/
& 5. Save the file&,
/*将单链表中记录保存到文件中*/
& 6. Load the file&,
/*从文件中读入记录*/
& 7. compute the score&,
/*计算所有学生的总分和均分*/
& 8. insert record to list &,
/*插入记录到表中*/
& 9. copy the file to new file&,
/*复制文件*/
& 10. sort to make new file&,
& 11. append
record to file&,
/*追加记录到文件中*/
& 12. index on nomber&,
& 13. total on nomber&,
/*分类合计*/
& 14. Quit&};
char s[3];
/*以字符形式保存选择号*/
/*定义整形变量*/
gotoxy(1,25);
/*移动光标*/
printf(&press any key enter menu......\n&);
/*压任一键进入主菜单*/
/*输入任一键*/
/*清屏幕*/
gotoxy(1,1);
/*移动光标*/
textcolor(YELLOW);
/*设置文本显示颜色为黄色*/
textbackground(BLUE);
/*设置背景颜色为蓝色*/
gotoxy(10,2);
/*移动光标*/
putch(0xc9);
/*输出左上角边框┏*/
for(i=1;i&44;i++)
putch(0xcd);
/*输出上边框水平线*/
putch(0xbb);
/*输出右上角边框
for(i=3;i&20;i++)
gotoxy(10,i);putch(0xba);
/*输出左垂直线*/
gotoxy(54,i);putch(0xba);
/*输出右垂直线*/
gotoxy(10,20);putch(0xc8);
/*输出左上角边框┗*/
for(i=1;i&44;i++)
putch(0xcd);
/*输出下边框水平线*/
putch(0xbc);
/*输出右下角边框┛*/
window(11,3,53,19);
/* 制作显示菜单的窗口,大小根据菜单条数设计*/
for(i=0;i&16;i++)
/*输出主菜单数组*/
gotoxy(10,i+1);
cprintf(&%s&,menu[i]);
textbackground(BLACK);
/*设置背景颜色为黑色*/
window(1,1,80,25);
/*恢复原窗口大小*/
gotoxy(10,21);
/*移动光标*/
printf(&\n
Enter you choice(0~14):&);
/*在菜单窗口外显示提示信息*/
scanf(&%s&,s);
/*输入选择项*/
c=atoi(s);
/*将输入的字符串转化为整形数*/
}while(c&0||c&14);
/*选择项不在0~14之间重输*/
/*返回选择项,主程序根据该数调用相应的函数*/}STUDENT *init(){
return NULL;}/*创建链表*/STUDENT *create(){
STUDENT *h=NULL,*
/* STUDENT指向结构体的指针*/
info=(STUDENT *)malloc(sizeof(STUDENT));
/*申请空间*/
/*如果指针info为空*/
printf(&\nout of memory&);
/*输出内存溢出*/
return NULL;
/*返回空指针*/
inputs(&enter no:&,info-&no,11);
/*输入学号并校验*/
if(info-&no[0]=='@')
/*如果学号首字符为@则结束输入*/
inputs(&enter name:&,info-&name,15); /*输入姓名,并进行校验*/
printf(&please input %d score \n&,N);
/*提示开始输入成绩*/
/*计算每个学生的总分,初值为0*/
for(i=0;i&N;i++)
/*N门课程循环N次*/
printf(&score%d:&,i+1);
/*提示输入第几门课程*/
scanf(&%d&,&info-&score[i]);
/*输入成绩*/
if(info-&score[i]&100||info-&score[i]&0) /*确保成绩在0~100之间*/
printf(&bad data,repeat input\n&);
/*出错提示信息*/
}while(info-&score[i]&100||info-&score[i]&0);
s=s+info-&score[i];
/*累加各门课程成绩*/
info-&sum=s;
/*将总分保存*/
info-&average=(float)s/N;
/*求出平均值*/
info-&order=0;
/*未排序前此值为0*/
info-&next=h;
/*将头结点做为新输入结点的后继结点*/
/*新输入结点为新的头结点*/
return(h);
/*返回头指针*/}/*输入字符串,并进行长度验证*/inputs(char *prompt, char *s, int count){
char p[255];
printf(prompt);
/*显示提示信息*/
scanf(&%s&,p);
/*输入字符串*/
if(strlen(p)&count)printf(&\n too long! \n&); /*进行长度校验,超过count值重输入*/
}while(strlen(p)&count);
strcpy(s,p); /*将输入的字符串拷贝到字符串s中*/}/*输出链表中结点信息*/还有一些代码没发完。;*输入记录*/
&quot,返回值整数作开关语句的条件*/
/*复制文件*/STUDENT *sort(STUDENT *h);
/*初始化链表*/
/*内存操作函数*/#include &
/*初始化函数*/STUDENT *create();
/*创建链表*/
/******头文件(.h)***********/#include &quot
{} 的作用是什么啊 ?什么时候该用什么时候不用啊?
#include &time.h&#include&stdio.h&#include&conio.h&#include &stdlib.h&#include&string.h&#define MAX 80void input();void sort();void display();void insert();void del();void average();void find();void save();void read();void del_file();void average();void modify();int now_no=0;struct student{ char name[20]; char sex[4]; float score1; float score2; float score3;};struct student stu[MAX],*p;main()/*主函数*/{ start: printf(&\n\t\t\t欢迎使用学生成绩管理系统\n&); /*一下为功能选择模块*/ do {
printf(&\n\t\t\t\t1.录入学员信息\n\t\t\t\t2.显示学员信息\n\t\t\t\t3.成绩排序信息\n\t\t\t\t4.添加学员信息\n\t\t\t\t5.删除学员信息\n\t\t\t\t6.修改学员信息\n\t\t\t\t7.查询学员信息\n\t\t\t\t8.从文件读入学员信息\n\t\t\t\t9.删除文件中学员信息\n\t\t\t\t10.保存学员信息\n\t\t\t\t11.退出\n&);
printf(&\t\t\t\t选择功能选项:&);
fflush(stdin);
scanf(&%d&,&as);
switch(as)
case 1:system(&cls&);input();
case 2:system(&cls&);display();
case 3:system(&cls&);sort();
case 4:system(&cls&);insert();
case 5:system(&cls&);del();
case 6:system(&cls&);modify();
case 7:system(&cls&);find();
case 8:system(&cls&);read();
case 9:system(&cls&);del_file();
case 10:system(&cls&);save();
case 11:system(&exit&);exit(0);
default:system(&cls&);
} }while(1); /*至此功能选择结束*/}void input()/*原始数据录入模块*/{ int i=0; do {
printf(&\t\t\t\t1.录入学员信息\n输入第%d个学员的信息\n&,i+1);
printf(&\n输入学生编号:&);
scanf(&%d&,&stu[i].no);
fflush(stdin);
printf(&\n输入学员姓名:&);
fflush(stdin);
gets(stu[i].name);
printf(&\n输入学员性别:&);
fflush(stdin);
gets(stu[i].sex);
printf(&\n输入学员成绩1:&);
fflush(stdin);
scanf(&%f&,&stu[i].score1);
printf(&\n输入学员成绩2:&);
fflush(stdin);
scanf(&%f&,&stu[i].score2);
printf(&\n输入学员成绩3:&);
fflush(stdin);
scanf(&%f&,&stu[i].score3);
printf(&\n\n&);
printf(&是否继续输入?(Y/N)&);
fflush(stdin);
ch=getch();
system(&cls&); } while(ch!='n'&&ch!='N'); system(&cls&);}void sort()/*排序数据函数*/{ int i,j; average(); for(i=1;i&now_i++) {
for(j=1;j&=now_no-i;j++)
if(stu[j-1].ave&stu[j].ave)
{ temp=stu[j];
stu[j]=stu[j-1];
} }}void display()/*显示数据函数*/{ average(); do {
printf(&\t\t\t班级学员信息列表\n&);
printf(&\t编号\t姓名\t性别\t成绩1\t成绩2\t成绩3\t平均值\n&);
for(i=0;i&now_no&&stu[i].name[0];i++)printf(&\t%d\t%s\t%s\t%.2f\t%.2f\t%.2f\t%.2f\n&,stu[i].no,stu[i].name,stu[i].sex,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].ave);
printf(&\t\t按任意键返回主菜单.&);
fflush(stdin);
as=getch(); } while(!as); system(&cls&);}void insert()/*插入数据函数*/{ do {
printf(&\n\t\t输入新插入学员队信息\n&);
printf(&\n输入学生编号:&);
scanf(&%d&,&stu[now_no].no);
fflush(stdin);
printf(&\n输入学员姓名:&);
fflush(stdin);
gets(stu[now_no].name);
printf(&\n输入学员性别:&);
fflush(stdin);
gets(stu[now_no].sex);
printf(&\n输入学员成绩1:&);
fflush(stdin);
scanf(&%f&,&stu[now_no].score1);
printf(&\n输入学员成绩2:&);
fflush(stdin);
scanf(&%f&,&stu[now_no].score2);
printf(&\n输入学员成绩3:&);
fflush(stdin);
scanf(&%f&,&stu[now_no].score3);
printf(&\n\n&);
now_no=now_no+1;
printf(&是否继续输入?(Y/N)&);
fflush(stdin);
ch=getch();
system(&cls&); } while(ch!='n'&&ch!='N');}void del()/*删除数据函数*/{ int inum,i,j; printf(&输入要删除学员的编号:&); fflush(stdin); scanf(&%d&,&inum); for(i=0;i&now_i++) {
if(stu[i].no==inum)
if(i==now_no)now_no-=1;
stu[i]=stu[now_no-1];
now_no-=1;
} } system(&cls&);}void save()/*保存数据函数*/{ FILE * char filepath[20]; printf(&输入要保存的文件路径:&); fflush(stdin); gets(filepath); if((fp=fopen(filepath,&w&))==NULL) {
printf(&\n保存失败!&);
exit(0); } for(i=0;i&now_i++) {
stu[i].sum=stu[i].score1+stu[i].score2+stu[i].score3;
stu[i].ave=stu[i].sum/3;
fprintf(fp,&\t%d\t%s\t%s\t%.2f\t%.2f\t%.2f\t%.2f\n&,stu[i].no,stu[i].name,stu[i].sex,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].ave); } fclose(fp);
printf(&学生信息已保存在%s中!\n&,filepath); system(&pause&); system(&cls&);}void find()/*查询函数*/{ char str[20], do {
printf(&输入要查询的学生姓名:&);
fflush(stdin);
gets(str);
for(i=0;i&now_i++)
if(!strcmp(stu[i].name,str))
printf(&\t编号\t姓名\t性别\t成绩1\t成绩2\t成绩3\t平均值\n&);
printf(&\t%d\t%s\t%s\t%.2f\t%.2f\t%.2f\t%.2f\n&,stu[i].no,stu[i].name,stu[i].sex,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].ave);
printf(&\t\t按任意键返回主菜单.&);
fflush(stdin);
as=getch(); } while(!as); system(&cls&);}void average()/*求平均数*/{ for(i=0;i&now_i++)
stu[i].sum=stu[i].score1+stu[i].score2+stu[i].score3;
stu[i].ave=stu[i].sum/3;
}}void modify()/*修改数据函数*/{ char str[20], printf(&输入要修改的学生姓名:&); fflush(stdin); gets(str); for(i=0;i&now_i++) if(!strcmp(stu[i].name,str)) {
system(&cls&);
printf(&\n\t\t输入新插入学员队信息\n&);
printf(&\n输入学生编号:&);
fflush(stdin);
scanf(&%d&,&stu[i].no);
printf(&\n输入学员性别:&);
fflush(stdin);
gets(stu[i].sex);
printf(&\n输入学员成绩1:&);
fflush(stdin);
scanf(&%f&,&stu[i].score1);
printf(&\n输入学员成绩2:&);
fflush(stdin);
scanf(&%f&,&stu[i].score2);
printf(&\n输入学员成绩3:&);
fflush(stdin);
scanf(&%f&,&stu[i].score3);
printf(&\n\n&);
sort(); } system(&cls&);}void read(){ FILE * char filepath[20]; printf(&输入要读入的文件路径:&); fflush(stdin); gets(filepath); if((fp=fopen(filepath,&r&))==NULL)
printf(&找不到%s文件!\n&,filepath);
system(&pause&);
} now_no=0; for(i=0;i&MAX&&!feof(fp);i++)
fscanf(fp,&\t%d\t%s\t%s\t%f\t%f\t%f\t%f\n&,&stu[i].no,stu[i].name,stu[i].sex,&stu[i].score1,&stu[i].score2,&stu[i].score3,&stu[i].ave);
} fclose(fp);
printf(&保存的在文件%s中的所有信息已经读入!\n&,filepath); system(&pause&); system(&cls&); }void del_file(){ FILE * char filepath[20]; printf(&输入要删除的文件路径:&); fflush(stdin); gets(filepath); fp=fopen(filepath,&w&); fclose(fp); printf(&保存的在文件%s中的所有信息已经删除!\n&,filepath); system(&pause&); system(&cls&); }
#include &iostream.h& // cin 及 cout #include &stdlib.h& #include &malloc.h& // 用到申请内存函数 malloc() 和释放内存函数 free() #include &string.h& // 字符串处理 #include &stdio.h& // 文件操作(读文件) struct address /*家庭地址*/ { char city[10]; /*城市*/ char town[10]; /*县城*/ char village[10]; /*乡镇*/ }; struct telephone /*联系方式*/ { char SJ[50]; /*手机*/ char JD[30]; /*家庭电话*/ char XD[30]; /*学校电话*/ }; struct person /*个人信息*/ { char name[20]; /*名字*/ char sex[10] ; /*性别*/ char MZ[16]; /*民族*/ char GJ[17]; /*国籍*/ char XL[19]; /*学历*/ }; struct score //成绩 { char num[20]; //学号 char english[20]; char chinese[20]; char math[20]; char physics[20]; }; typedef struct linknode //定义节点的类型 { char address[100]; //地址 char birthday[100]; //出生日期
//个人信息
//联系方式
struct linknode* } class List { nodetype* public: List(); List::~List(); linknode* creatlist(int); //创建链表 int listlen(); //返回链表长度 nodetype* findnode(int); //通过查找序号返回节点的指针 nodetype* find(char c[]); //通过查找姓名返回节点的指针 int find2(char c[]); //通过查找姓名返回节点的序号 nodetype* insnode(int); //插入节点 void delnode(int); //删除节点 nodetype* load(); //初始化:从外部读入数据 void readstr(FILE *f,char *string); //读行函数 bool check(char *a, char *b); //对比两个字符串是否相等 void help(); //显示帮助菜单 void editperson(nodetype*); //编辑个人说明 void editscore(nodetype*); //编辑学科成绩 void edittelephone(nodetype*); //编辑联系方式 void dispname(); //显示所有学生姓名 void dispnode(nodetype* p); //显示一个学生的所有信息 void dispperson(nodetype*); //显示一个学生的个人说明 void dispscore(nodetype*); //显示一个学生的学科成绩 void disptelephone(nodetype*); //显示一个学生的联系方式 }; bool List::check(char *a, char *b) //对比两个字符串是否相等 {
int j=strlen(b); for(i=0; i&j; i++) { if(*a==*b) { a++; b++; } else return 0; } return 1; } nodetype* List::creatlist (int n) //创建链表 { nodetype *h=NULL, *s, *t; int i=1; for(int j=0; j&n; j++) { if(i==1) //创建第一个节点 { h=(nodetype*)malloc(sizeof(nodetype)); h-&next=NULL; t=h; } else //创建其余节点 { s=(nodetype*)malloc(sizeof(nodetype)); s-&next=NULL; t-&next=s; t=s; //t 始终指向生成的单链表的最后一个节点 } i++; } head=h;
} void List::readstr(FILE *f,char *string) { do { //①: 先读入一行文本 fgets(string, 255, f); //fgets(): 从文件 f 读入长度为 255-1 的字符串 // 并存入到 string 中 } while ((string[0] == '/') || (string[0] == '\n'));
} nodetype* List::load() { FILE * nodetype *p; char c[255];
if((fp=fopen(&student.txt&, &r&))==NULL) { cout&&&打开文件失败&&& return 0; } readstr(fp, c); sscanf(c, &The Length Of Link: %d&, &num); //获取链表长度 p=creatlist(num); //创建链表 for(int i=0; i& i++) { readstr(fp, c); strcpy(p-&address, c); readstr(fp, c); strcpy(p-&birthday, c); readstr(fp, c); strcpy(p-&sc.num, c); readstr(fp, c); strcpy(p-&sc.chinese, c); readstr(fp, c); strcpy(p-&sc.english, c); readstr(fp, c); strcpy(p-&sc.math, c); readstr(fp, c); strcpy(p-&sc.physics, c); readstr(fp, c); strcpy(p-&pe.name, c); readstr(fp, c); strcpy(p-&pe.sex, c); readstr(fp, c); strcpy(p-&pe.GJ, c); readstr(fp, c); strcpy(p-&pe.MZ, c); readstr(fp, c); strcpy(p-&pe.XL, c); readstr(fp, c); strcpy(p-&te.SJ, c); readstr(fp, c); strcpy(p-&te.JD, c); readstr(fp, c); strcpy(p-&te.XD, c); p=p-& } fclose(fp);
} void List::dispnode(nodetype* p) //显示一个学生的所有信息 { if(p!=NULL) { dispperson(p); dispscore(p); disptelephone(p); } } void List::dispname() //显示所有学生姓名 { nodetype* p= cout&&&现有的学生: &&& if(p==NULL) cout&&&没有任何学生数据&&& while(p!=NULL) { cout&&&姓名: &&&p-&pe. p=p-& } } int List::listlen() //返回链表长度 { int i=0; nodetype* p= while(p!=NULL) { p=p-& i++; }
} nodetype* List::findnode (int i) //通过查找序号返回节点的指针 { nodetype* p= int j=1; if( i&listlen()||i&=0 ) // i 上溢或下溢 return NULL; else { while( p!=NULL && j&i ) //查找第 i 个节点并由 p 指向该节点 { j++; p=p-& }
} } nodetype* List::find(char c[]) //通过查找姓名返回节点的指针 { nodetype* p= int j=1; strcat(c, &\n&); //从外部读入的字符串末尾都带了一个换行符 while( p!=NULL && !(check(c, p-&pe.name))) //查找第 i 个节点并由 p 指向该节点 { j++; p=p-& }
} int List::find2(char c[]) //通过查找姓名返回节点的序号 { nodetype* p= int j=1; strcat(c, &\n&); //从外部读入的字符串末尾都带了一个换行符 while( p!=NULL && !(check(c, p-&pe.name))) //查找第 i 个节点并由 p 指向该节点 { j++; p=p-& }
} nodetype* List::insnode(int i) { nodetype *h=head, *p, *s; s=(nodetype*)malloc(sizeof(nodetype)); //创建节点 s s-&next=NULL; if(i==0) //i=0 时 s 作为该单链表的第一个节点 { s-&next = h=s; //重新定义头节点 } else { p=findnode(i); //查找第 i 个节点,并由 p 指向该节点 if(p!=NULL) { s-&next=p-& p-&next=s; } else cout&&&输入的 i 值不正确&&& } head=h;
} void List::delnode(int i) //删除第 i 个节点 { nodetype *h=head, *p=head, *s; int j=1; if(i==1) //删除第一个节点 { h=h-& free(p); } else { p=findnode(i-1); //查找第 i-1 个节点,并由 p 指向这个节点 if(p!=NULL && p-&next!=NULL) { s=p-& // s 指向要删除的节点 p-&next=s-& free(s); } else cout&&&输入的 i 值不正确&&& } head=h; } void List::editperson(nodetype* p) { char c[100]; cout&&&请输入姓名: &&& cin&&c; strcat(c, &\n&); strcpy(p-&pe.name, c); cout&&&请输入性别:&&& cin&&c; strcat(c, &\n&); strcpy(p-&pe.sex, c); cout&&&请输入生日(格式举例:): &&& cin&&c; strcat(c, &\n&); strcpy(p-&birthday, c); cout&&&请输入民族:&&& cin&&c; strcat(c, &\n&); strcpy(p-&pe.MZ, c); cout&&&请输入国籍:&&& cin&&c; strcat(c, &\n&); strcpy(p-&pe.GJ, c); cout&&&请输入学历:&&& cin&&c; strcat(c, &\n&); strcpy(p-&pe.XL, c); cout&&&请输入家庭住址(例如:广西玉林市解放路11号)&&& cin&&c; strcat(c, &\n&); strcpy(p-&address, c); cout&&&编辑个人信息完成!&&& dispperson(p); } void List::editscore(nodetype* p) { char a[50]; cout&&&请输入学号: &&& cin&&a; strcat(a, &\n&); strcpy(p-&sc.num, a); cout&&&请输入语文成绩: &&& cin&&a; strcat(a, &\n&); strcpy(p-&sc.chinese, a); cout&&&请输入英语成绩: &&& cin&&a; strcat(a, &\n&); strcpy(p-&sc.english, a); cout&&&请输入数学成绩: &&& cin&&a; strcat(a, &\n&); strcpy(p-&sc.math, a); cout&&&请输入物理成绩: &&& cin&&a; strcat(a, &\n&); strcpy(p-&sc.physics, a); cout&&&编辑学科成绩完成!&&& dispscore(p); } void List::edittelephone(nodetype* p) { char c[50]; cout&&&请输入手机号码: &&& cin&&c; strcat(c, &\n&); strcpy(p-&te.SJ, c); cout&&&请输入家庭电话号码: &&& cin&&c; strcat(c, &\n&); strcpy(p-&te.JD, c); cout&&&请输入学校电话号码: &&& cin&&c; strcat(c, &\n&); strcpy(p-&te.XD, c); cout&&&编辑联系方式完成!&&& disptelephone(p); } void List::dispperson(nodetype* p) { cout&&&姓名: &&&p-&pe. cout&&&性别: &&&p-&pe. cout&&&民族: &&&p-&pe.MZ; cout&&&国籍: &&&p-&pe.GJ; cout&&&学历: &&&p-&pe.XL; cout&&&出生日期: &&&p-& cout&&&家庭住址: &&&p-& } void List::dispscore(nodetype* p) { cout&&&学号: &&&p-&sc. cout&&&语文成绩: &&&p-&sc. cout&&&英语成绩: &&&p-&sc. cout&&&数学成绩: &&&p-&sc. cout&&&物理成绩: &&&p-&sc. } void List::disptelephone(nodetype* p) { cout&&&手机号码是: &&&p-&te.SJ; cout&&&家庭电话是: &&&p-&te.JD; cout&&&学校电话是: &&&p-&te.XD; } void List::help() { cout&&endl&& cout&&&*********************************************************&&& cout&&&1: 编辑个人信息&&& cout&&&2: 编辑学科成绩&&& cout&&&3: 编辑联系方式&&& cout&&&4: 显示个人信息&&& cout&&&5: 显示学科成绩&&& cout&&&6: 显示联系方式&&& cout&&&7: 显示该学生所有信息&&& cout&&&8: 帮助菜单&&& cout&&&9: 返回上一级菜单&&& cout&&&*********************************************************&&& } List::~List() { nodetype *pa=head, * if(pa!=NULL) { pb=pa-& if(pb==NULL) free(pa); else { while(pb!=NULL) { free(pa); pa= pb=pb-& } free(pa); } } } class Operater { List L1; public: void Loop(); //主循环 void display(); //显示菜单 }; List::List() { head = NULL; } void Operater::display() { cout&&endl&& cout&&&**************************** 学生管理系统 **************************&&& cout&&&1: 添加一个学生信息&&& cout&&&2: 删除一个学生信息&&& cout&&&3: 显示所有学生的姓名&&& cout&&&4: 根据姓名显示单个学生所有信息&&& cout&&&5: 根据姓名对单个学生进行编辑&&& cout&&&6: 帮助菜单&&& cout&&&7: 保存数据&&& cout&&&0: 退出系统&&& cout&&&********************************************************************&&& } void Operater::Loop() { List L1; //List 对象 char ch[20]; nodetype *p, *
//存放节点序号 p=L1.load(); //初始化:从外部读入数据创建链表 head=p; display(); while(1) { cout&&endl&& cout&&&请输入选择(帮助选项--& 6 ): &&& cin&& ////system(&cls&); if(L1.check(ch, &1&)) { p=L1.insnode(0); head=p; //system(&cls&); cout&& cout&&&************** 添加一个学生信息 ******************&&& cout&&&下面输入个人信息: &&& L1.editperson(p); cout&&&下面输入学科成绩: &&& L1.editscore(p); cout&&&下面输入联系方式: &&& L1.edittelephone(p); } if(L1.check(ch, &2&)) { //system(&cls&); cout&& cout&&&************** 删除一个学生信息 ******************&&& L1.dispname(); cout&&&请输入学生姓名: &&& cin&& i=L1.find2(ch); L1.delnode(i); } if(L1.check(ch, &3&)) { //system(&cls&); cout&& cout&&&************** 显示所有学生姓名 ******************&&& L1.dispname(); } if(L1.check(ch, &4&)) { //system(&cls&); cout&& cout&&&************** 根据姓名显示单个学生所有信息 ******************&&& L1.dispname(); cout&&&请输入学生姓名: &&& cin&& p=L1.find(ch); L1.dispnode(p); } if(L1.check(ch, &6&)) { display(); } if(L1.check(ch, &7&)) //保存数据 { FILE * if((fp=fopen(&student.txt&, &w&))==NULL) { cout&&&打开文件失败&&&
char t[255]; //将 L1.listlen() 赋予字符串中的数字 sprintf(t, &The Length Of Link: %d\n&, L1.listlen()); fputs(t, fp); strcpy(t, &\n&); fputs(t, fp); p=L1.findnode(1); //将链表头指针赋予 p for(i=0; i&L1.listlen(); i++) { fputs(p-&address, fp); //输出地址 fputs(p-&birthday, fp); //输出生日 fputs(p-&sc.num, fp); //输出学号 fputs(p-&sc.chinese, fp); //输出语文成绩 fputs(p-&sc.english, fp); //输出英语成绩 fputs(p-&sc.math, fp); //输出数学成绩 fputs(p-&sc.physics, fp); //输出物理成绩 fputs(p-&pe.name, fp); //输出姓名 fputs(p-&pe.sex, fp); //输出性别 fputs(p-&pe.GJ, fp); //输出国籍 fputs(p-&pe.MZ, fp); //输出民族 fputs(p-&pe.XL, fp); //输出学历 fputs(p-&te.SJ, fp); //输出手机 fputs(p-&te.JD, fp); //输出家庭电话 fputs(p-&te.XD, fp); //输出学校电话 fputs(t, fp); p=p-& } p= fclose(fp); } if(L1.check(ch, &5&)) { char c[20]; //system(&cls&); cout&& cout&&&************** 根据姓名对单个学生进行编辑 ******************&&& L1.dispname(); cout&&&请输入学生姓名: &&& cin&&c; p=L1.find(c); //system(&cls&); cout&&endl&& cout&&&*********************************************************&&& cout&&&1: 编辑个人信息&&& cout&&&2: 编辑学科成绩&&& cout&&&3: 编辑联系方式&&& cout&&&4: 显示个人信息&&& cout&&&5: 显示学科成绩&&& cout&&&6: 显示联系方式&&& cout&&&7: 显示该学生所有信息&&& cout&&&8: 帮助菜单&&& cout&&&9: 返回上一级菜单&&& cout&&&*********************************************************&&& while(1) { cout&&endl&& cout&&&请输入选择(帮助选项--& 8 ): &&& cin&&c; //system(&cls&); if(L1.check(c, &1&)) { //system(&cls&); cout&& cout&&&************** 编辑个人信息 ******************&&& L1.editperson(p); } else if(L1.check(c, &2&)) { //system(&cls&); cout&& cout&&&************** 编辑学科成绩 ******************&&& L1.editscore(p); } else if(L1.check(c, &3&)) { //system(&cls&); cout&& cout&&&************** 编辑联系方式 ******************&&& L1.edittelephone(p); } else if(L1.check(c, &4&)) { //system(&cls&); cout&& cout&&&************** 显示个人信息 ******************&&& L1.dispperson(p); } else if(L1.check(c, &5&)) { //system(&cls&); cout&& cout&&&************** 显示学科成绩 ******************&&& L1.dispscore(p); } else if(L1.check(c, &6&)) { //system(&cls&); cout&& cout&&&************** 显示联系方式 ******************&&& L1.disptelephone(p); } else if(L1.check(c, &7&)) { //system(&cls&); L1.dispnode(p); } else if(L1.check(c, &8&)) { //system(&cls&); L1.help(); } else if(L1.check(c, &9&)) { display();
//用 break 跳出本循环,不要用 return ,return 是退出程序 } } } else if(L1.check(ch, &0&))
} int main() { system(&color 3A&); O chp.Loop(); return 0; }绝对可以用的
其他2条回答
为您推荐:
其他类似问题
您可能关注的内容
c语言的相关知识
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。

我要回帖

更多关于 用c语言编写心形 的文章

 

随机推荐