开发者社区> 问答> 正文

关于 按钮 点击倒计时的问题

默认 int state=1;

如果state=1的话 就提示已发送通知 并且把state设为2

当state不等于1时 提示已经发送通知,再过time秒在发送吧

time来自于一个倒计时的类

现在的问题是 当我点击后 倒计时还没走完 我关闭页面 再进 state又是开始的1了

又回到原来的了 所以有什么好办法吗
screenshot

展开
收起
爵霸 2016-03-03 16:28:16 1882 0
1 条回答
写回答
取消 提交回答
  • 虽然花了好长时间大致看懂了,但做起来却想当然了,导致提交总是wrong answer,认真反复思考过后,终于完成了这题,所以,以后做题先在稿纸上规划好,不急着打代码,边敲边想,想好了之后再敲代码,那样会是事半功倍滴!

    Description
    
    Bessie the cow is getting bored of the milk production industry, and wants to switch to an exciting new career in computing. To improve her coding skills, she decides to compete in the on-line competitions. Since she notes that the contest starts on November 11, 2011 (11/11/11), she decides for fun to download the problems and begin coding at exactly 11:11AM on 11/11/11. 
    
    Unfortunately, Bessie's time management ability is quite poor, so she wants to write a quick program to help her make sure she does not take longer than the 3 hour (180 minute) time limit for the contest. Given the date and time she stops working, please help Bessie compute the total number of minutes she will have spent on the contest. 
    Input
    
    * Line 1: This line contains 3 space-separated integers, D H M,specifying the date and time at which Bessie ends the contest. D will be an integer in the range 11..14 telling the day of the month; H and M are hours and minutes on a 24-hour clock(so they range from H=0,M=0 at midnight up through H=23,M=59 at 11:59 PM). 
    
    Output
    
    * Line 1: The total number of minutes spent by Bessie in the contest,or -1 if her ending time is earlier than her starting time.
    Sample Input
    12 13 14
    Sample Output
    1563
    #include <stdio.h>
    #include <stdlib.h>
    int main()
    {
        int D,H,M,total;
        int flag=-1;
        while(scanf("%d %d %d",&D,&H,&M)!=EOF)
        {    if (D<11||D>14)
            {printf("%d\n",flag);break;}
            if (H<0||H>23)
            {printf("%d\n",flag);break;}
            if(M<0||M>59)
            {printf("%d\n",flag);break;}
            if(D==11)
            {
               if(H<11||H>23)
               {printf("%d\n",flag);break;}
               if(M<11||M>59)
               {printf("%d\n",flag);break;}
    
               total=H*60+M-671;
            }
            else if(D==12) total=24*60+H*60+M-671;
               else if(D==13)total=48*60+H*60+M-671;
                else if(D==14)total=72*60+H*60+M-671;
        printf("%d",total);
        }
    
        return 0;
    }
    2019-07-17 18:51:37
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载