数据结构课程设计--电子投票系统

/***********************************************************
* 版权所有 (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
  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值