| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1686 人关注过本帖
标题:[求助]一个C++程序来看看
只看楼主 加入收藏
Qup
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2006-12-7
收藏
 问题点数:0 回复次数:15 
[求助]一个C++程序来看看

#include<iostream>
#include<iomanip>
#include<string>
#include<fstream>
#define N 10
using namespace std;
class MonthPunchIn //月出勤情况文件
{
public:
int num,thlate,thabsent,thask;//学号,迟到次数,请假天数,旷课天数
string name; //姓名


};
class punchIn:public MonthPunchIn//以时间计算迟到的次数
{
public:
int hour,minute,second,ask;
void late()
{
if(hour>8)
{
for(int i=0;i<6;i++)
if(minute>10*i&&minute<(10*i+10))
thlate+=(i+1);
}
}
int judgelate()//计算迟到数
{
int judge=0;
if(hour>8) judge++;
return judge;
}
int latetime()
{
int sum;
sum=hour*10000+minute*100+second;
return sum;
}

void absent(int s[N])//计算请假数,缺席数
{
ask=0;
for(int i=0;i<N;i++)
if(num==s[i]) ask++;
if(hour=='\0')
{
thabsent++;
if(ask)
{
thabsent--;
thask++;
}
}
}
};

void fun::list1()
{ cout<<setw(3)<<num<<" 到课时间"<<hour<<"时"<<minute<<"分"<<second<<"秒 迟到"<<monthlate<<"次 请假"<<monthask<<"天 旷课"<<thabsent<<"天";
cout<<endl;
}
void fun::list2()
{
cout<<setw(3)<<num<<" "<<name;
cout<<endl;
}

void fun::list3()
{
if(thask>5)
cout<<setw(3)<<num<<" "<<name<<" "<<birth<<" 请假"<<monthask<<"天";
cout<<endl;
}

void fun::list4()
{
if(thabsent!=0)
cout<<setw(3)<<num<<" "<<name<<" "<<birth<<" 迟到"<<thlate<<"天 请假"<<thask<<"天 旷课"<<thabsent<<"天";
cout<<endl;
}

void fun::list5()
{
cout<<setw(3)<<num<<" "<<name<<endl;
}
void main()
{
fun per[11];

per[1].thlate=2;//列举学生的基本信息
per[1].thabsent=3;
per[1].thask=4;
per[1].hour=8;
per[1].minute=10;
per[1].second=05;
per[1].num=1;
per[1].name="jiangwen";


per[2].monthlate=5;
per[2].monthabsent=4;
per[2].monthask=3;
per[2].hour=8;
per[2].minute=40;
per[2].second=10;
per[2].num=2;
per[2].name="huangwei";

per[3].monthlate=4;
per[3].monthabsent=1;
per[3].monthask=0;
per[3].hour=8;
per[3].minute=30;
per[3].second=30;
per[3].num=3;
per[3].name="jiayin";

per[4].thlate=3;
per[4].thabsent=1;
per[4].thask=1;
per[4].hour=8;
per[4].minute=20;
per[4].second=10;
per[4].num=4;
per[4].name="zhangzao";

per[5].thlate=2;
per[5].thabsent=0;
per[5].thask=0;
per[5].hour=8;
per[5].minute=20;
per[5].second=0;
per[5].num=5;
per[5].name="miaojinhua";

per[6].thlate=1;
per[6].thabsent=1;
per[6].thask=2;
per[6].hour=7;
per[6].minute=20;
per[6].second=0;
per[6].num=6;
per[6].name="haoxiuqing";

per[7].thlate=5;
per[7].thabsent=4;
per[7].thask=8;
per[7].hour=8;
per[7].minute=40;
per[7].second=30;
per[7].num=7;
per[7].name="baineng";

per[8].thlate=2;
per[8].thabsent=3;
per[8].thask=2;
per[8].hour=8;
per[8].minute=20;
per[8].second=0;
per[8].num=8;
per[8].name="liumin";

per[9].thlate=2;
per[9].thabsent=1;
per[9].thask=1;
per[9].hour=8;
per[9].minute=20;
per[9].second=0;
per[9].num=9;
per[9].name="guojin";

per[10].thlate=2;
per[10].thabsent=2;
per[10].thask=3;
per[10].hour=8;
per[10].minute=20;
per[10].second=0;
per[10].num=10;
per[10].name="wutianzhen";

int i,j,p;
int c0,c1,c2,c3;
int year,month,s[N];

cout<<"************************"<<endl;
cout<<"*****出勤卡数据管理*****"<<endl;
cout<<"************************"<<endl;
ff: cout<<"输入今年的年份:"<<endl;
cin>>year;
if(year>2006){cout<<"error!重新输入!"<<endl;goto ff;}
ss: cout<<"输入这个月的月份:"<<endl;
cin>>month;
if(month<1||month>12){cout<<"error!重新输入!"<<endl;goto ss;}

for(i=1;i<=N;i++)
{
per[i].late();
per[i].absent(s);
per[i].count(year,month);
}

k0:
cout<<"**********************************************************************"<<endl;
cout<<"选择需要使用的功能:"<<endl;
cout<<"1 查询"<<endl;
cout<<"2 统计"<<endl;
cout<<"3 排序"<<endl;
cin>>c0;

if(c0==1)
{
k1:
cout<<"**********************************************************************"<<endl;
cout<<"查询:"<<endl;
cout<<"1 按学生学号查询当日到课时间,当月出勤情况:"<<endl;
cout<<"2 列出所有全勤学生的清单:"<<endl;
cout<<"3 列出请假天数超过五天的学生情况:"<<endl;
cout<<"4 列出有旷课行为的全体学生的情况:"<<endl;
cout<<"输入需要查询的项目:"<<endl;
cin>>c1;

if(c1==1)
{
int n;
cout<<"输入需要查询的学生学号:"<<endl;
cin>>n;

for(int i=1;i<=N;i++)
{
if(per[i].num==n) per[i].list1();
}
}


if(c1==2)
{
int allfull=0;
for(i=1;i<=N;i++)
{
if(per[i].allpresent())
{
per[i].list2();
allfull++;
}
}

if(allfull==0)
{
cout<<"当月没有全勤学生!"<<endl;
}
}


if(c1==3)

{
for(i=1;i<=N;i++)
per[i].list3();
}

if(c1==4)
{
for(i=1;i<=N;i++)
per[i].list4();
}


char con1;
cout<<"继续查询按y 返回主菜单按n 按其他任意键+Enter退出:";
cin>>con1;
if(con1=='y') goto k1;
else if (con1=='n')goto k0;

}


if(c0==2)
{
k2:
cout<<"**********************************************************************"<<endl;
cout<<"统计:"<<endl;
cout<<"1 计算当前学生总数"<<endl;
cout<<"2 计算当月全勤学生总数及占全体学生的百分比"<<endl;
cout<<"3 计算当日迟到时间"<<endl;
cout<<"4 计算当月请假天数"<<endl;
cout<<"5 计算当月迟到次数"<<endl;
cout<<"6 计算当月旷课的最大天数"<<endl;
cout<<"7 计算当日迟到的学生总数及占学生总数的百分比"<<endl;
cout<<"输入需要统计的项目:"<<endl;
cin>>c2;

if(c2==1)
{

cout<<"当前学生总数:"<<N<<endl;
}


if(c2==2)
{
int n=0;
for(int i=1;i<=N;i++)
if(per[i].allpresent()) n++;
cout<<"当月全勤学生总数:"<<n<<endl;

cout<<"当月全勤学生占全体学生的百分比:"<<float(n)/N*100<<"%"<<endl;
}


if(c2==3)
{
int daylate;
daylate=per[1].latetime-80000;
for(i=1;i<=N;i++)
{
if(daylate<(per[i].latetime-80000))
daylate=per[i].latetime-80000;
}
cout<<"当日迟到时间:"<<daylate/100<<"分"<<daylate-100*(daylate/100)<<"秒"<<endl;
}

if(c2==4)
{
long ask;
ask=per[1].thask;
for(i=1;i<=N;i++)
{
if(ask<per[i].thask)
sk=per[i].thask;
}
cout<<"当月请假天数:"<<ask<<endl;
}

if(c2==5)
{
long late;
late=per[1].thlate;
for(i=1;i<=N;i++)
{
if(late<per[i].thlate)
late=per[i].thlate;
}
cout<<"当月迟到次数:"<<late<<endl;
}


if(c2==6)
{
long absent;
absent=per[1].thabsent;
for(i=1;i<=N;i++)
{
if(absent<per[i].thabsent)
absent=per[i].thabsent;
}
cout<<"当月旷课天数:"<<absent<<endl;
}

if(c2==7)
{
int latesum=0;
for(i=1;i<=N;i++)
{
if(per[i].latetime>80000)
latesum++;

}
cout<<"当日迟到学生总数:"<<latesum<<endl;

cout<<"当日迟到学生总数占学生总数百分比:"<<float(latesum)/N*100<<"%"<<endl;
}
char con2;
cout<<"继续统计按y 返回主菜单按n 按其他任意键+Enter退出:";

要求做的:

出勤管理系统
学生学号
学生姓名
课程名称
上课时间
到课时间
出勤状态 [旷课/病假/事假/迟到/早退]

能够对数据进行增、删、改、查操作。
能够按学号顺序列出某一课程的出勤状况。
。。。
具体的问题和改动请帮帮忙

搜索更多相关主题的帖子: void include public minute 
2006-12-12 21:47
Qup
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2006-12-7
收藏
得分:0 

没人来 偶自己顶下

2006-12-12 21:48
Qup
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2006-12-7
收藏
得分:0 
帮帮偶改改   偶先谢谢了
2006-12-12 21:51
yuyunliuhen
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:1435
专家分:0
注 册:2005-12-12
收藏
得分:0 

虽然帮不上忙, 还是得顶下先


Go confidently in the  directions of your dreams,live the life you have imagined!Just do it!
It is no use learning without thinking!
2006-12-12 22:03
malwater
Rank: 1
等 级:新手上路
帖 子:50
专家分:0
注 册:2004-12-11
收藏
得分:0 
N久没有发言了,顶一下就是了!

菜鸟何时成老鸟? 十年苦学几时笑? 专心学E好多年! 菜鸟总会变老鸟~
2006-12-13 08:20
song4
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:38
帖 子:1533
专家分:4
注 册:2006-3-25
收藏
得分:0 
你哪里错了

嵌入式 ARM 单片机 驱动 RT操作系统 J2ME LINUX  Symbian C C++ 数据结构 JAVA Oracle 设计模式 软件工程 JSP
2006-12-13 09:02
一二三四五
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:856
专家分:0
注 册:2006-11-13
收藏
得分:0 
不是写得挺好的吗

hey,di va la
2006-12-13 09:17
Qup
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2006-12-7
收藏
得分:0 
不会吧?运行有102个错误啊
2006-12-13 14:31
shengwumozhe
Rank: 1
等 级:新手上路
帖 子:54
专家分:0
注 册:2006-10-24
收藏
得分:0 
...............102个。。。。。。。。。。。。。。
编译器有问题吧。。。。。。。。。。。。。。

自信,微笑^_^
2006-12-13 17:18
noviceby
Rank: 1
等 级:新手上路
帖 子:51
专家分:0
注 册:2006-12-13
收藏
得分:0 
看得我头都晕了,程序里void fun::list1() fun是类吧?程序里没有定义啊,程序是不是你写的啊,那么乱

[此贴子已经被作者于2006-12-13 22:12:41编辑过]



我是菜鸟我怕谁?
2006-12-13 22:09
快速回复:[求助]一个C++程序来看看
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.036507 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved