签到

05月08日
尚未签到

共有回帖数 0

    李小主任

    等级:
     至从买了电脑,宿舍里人就不上课了,为了防止这一点,写了一个小程序
      第天开机时自动运行,检查今天是星期几,然后用SWITCH根据不同的日期,限制不同的时间(就是输进课程表的时间)。调系统时间,如果这时候在上课时间里,那么系统自动关机
    #include"stdio.h"
    #include"dos.h"
    main()
    {
    int p;
    int month,day,sum;
    struct time t[1];
    struct date d;
    getdate(&d);    /* 调系统日期,检测查是星期几*/
    month=d.da_mon-11;
    day=d.da_day-20;
    sum=month*31+day;
    p=sum%7;
    gettime(t);  /*调系统时间*/
    switch (p)
    {
    case 1:      /*星期一的时候*/
         if(t[0].ti_hour=11)  system("shutdown -s");
         
    case 2:
         if(t[0].ti_hour17)  system("shutdown -s");
         
    case 3:if(t[0].ti_hour12||t[0].ti_hour=14&&t[0].ti_hour16) system("shutdown -s");
         
    case 4:if(t[0].ti_hour10) system("shutdown -s");
         
    case 5:if(t[0].ti_hour=14&&t[0].ti_hour16) system("shutdown -s");
         
    case 6:
         exit(0);
    case 7:
         exit(0);
    }
    }

    楼主 2016-02-12 14:20 回复

共有回帖数 0
  • 回 帖
  • 表情 图片 视频
  • 发表

登录直线网账号

Copyright © 2010~2015 直线网 版权所有,All Rights Reserved.沪ICP备10039589号 意见反馈 | 关于直线 | 版权声明 | 会员须知