免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1022 | 回复: 0
打印 上一主题 下一主题

这个程序有问题吗? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-06-21 20:19 |只看该作者 |倒序浏览
#ifndef TIME2_H
#define TIME2_H
class time2{
public:
        time2(int=0,int=0,int=0);
        void setime(int,int,int);
        void printmilitary();
        void printstander();
private:
        int hour;
        int minute;
        int second;
};
# endif

#include<iostream.h>
#include "time2.h"
time2::time2(int h,int m,int s){
        settime(hor,mi,se);
}
void time2::setime(int h,int m int s){
        hour=((h>=0&&h<24)? h:0);
        minute=((m>=0&&m<24)? m:0);
        second=((s>=0&&s<24)? s:0);
}
void time2::printmilitary(){
        cout<<((hour<10)? "0":""<<hour<<":"<<((minute<10)? "0":""<<minute<<":"<<second<<endl;
}
void time2::printstander(){
        cout<<((hour==0||hour==12)? "0":hour%12)<<":"<<((minute<10)? "0":""<<minute<<":"<<second<<endl;
}


#include<iostream.h>
#include "time2"
void main(){
        time2 t,
                  t1(1,
                  t2(18,30),
                  t3(18,30,0);
        cout<<"the defult time output is"<<endl;
        t.printmilitary();
        t.printstander();
        cout<<endl;
        cout<<"the first time output is"<<endl;
        t1.printmilitary();
        t1.printstander();
        cout<<endl;
        cout<<"second time by defult is"<<endl;
        t2.printmilitary();
    t2.printstander();
        cout<<endl;
        cout<<"the three time by defult is"<<endl;
        t3.printmilitary();
        t3.printstander();
        cout<<endl;
}
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP