/***********************************************************
* 版权所有 (C)2016, Yu Suxian
*
* 文件名称: ysxcpp
* 文件标识:无
* 内容摘要:该代码用于获取满足后缀要求的第一个文件
* 其它说明:无
* 当前版本: V1.0
* 作 者:于苏显
* 完成日期: 20161227
*
* 修改记录2:
* 修改日期: 20161229
* 版本号: V1.0
* 修改人: Yu Suxian
* 修改内容:完善和修改部分功能,如录入和欢迎界面**********************************************************/
头文件 vote.h
#include <windows.h>
#include <iostream>
using namespace std;
#include <fstream>
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
# include "conio.h" //getch()不回显函数 自动读取
typedef struct student
{
char number[20];
char name[20];
char sex[20];
char Job[20];
int piao;
struct student *next;
} stu;
void outfile(stu *head);
void disp1(stu *p); //显示全部信息(学生界面)
void disp2(stu *p); //显示全部信息(管理员界面)
void vote(stu *h);//投票
stu *add(stu *head);//录入
stu *delet(stu *p0);//删除
stu *change(stu *h);//修改
void find(stu *h);//查询
stu *arrange(stu *head);//查看投票情况(选择排序)
int MainMenu();//主界面
int ManageMenu();//管理员界面
int StudentMenu();//学生界面
int welcome0();
源文件 vote.cpp
#include "vote.h"
void outfile(stu *head)
{
stu *p=head;
FILE *fp;
int ch;
ofstream outfile("output.txt",ios::app);
if(!outfile)//未成功打开文件
{
exit(1);
}
fp=fopen("output.txt","r");
ch=fgetc(fp);
if ( ch==EOF )
{
outfile<<"学号 姓名 性别 目前职务 票数";
outfile<<"\r\n";//回车换行
}
while(p)
{
outfile<<" "<<p->number<<" "<<p->name<<" "<<p->sex<<" "<<p->Job<<" "<<p->piao;
outfile<<"\r\n";
p=p->next;
}
outfile.close();
}
void disp1(stu *p) //显示全部信息(学生界面)
{
if(p==NULL)
{
printf("\n信息出错!按任意键退出!");
getch();
return ;
}
while (p)
{
printf("\n学号:%s 姓名:%s 性别:%s 目前职务:%s \n", p->number, p->name, p->sex, p->Job);
p = p->next;
}
printf("\n按任意键继续!");
getch();
}
void disp2(stu *p) //显示全部信息(管理员界面)
{
while (p)
{
printf("\n学号:%s 姓名:%s 性别:%s 目前职务:%s 得票:%d\n", p->number, p->name, p->sex, p->Job,p->piao);
p = p->next;
}
getch();
}
stu *add(stu *head) //录入
{
int al=0;
int piao;
char num[20];
stu *p,*q;
p =new stu;
q=head;
printf("\n请输入学生信息:\n");
printf("\n学号:");
scanf("%s", num);
while(q)
{
if(strcmp(q->number, num)==0)
{
al=1;
break;
}
else q = q->next;
}
if(al==0)
{
strcpy(p->number,num);
printf("\n姓名:");
scanf("%s", p->name);
printf("\n性别:");
scanf("%s", p->sex);
printf("\n目前职务:");
scanf("%s", p->Job);
printf("\n得票:");
scanf("%d", &piao);
p->piao = piao;
if (head!= NULL)
{
p->next = head;
head = p;
}
e