zoukankan      html  css  js  c++  java
  • 112.备忘录设计模式

    • 备忘录模式
       1 //备忘录模式
       2 void foget()
       3 {
       4     //不断获取鼠标位置
       5     for (int i = 0; i < 1000; i++)
       6     {
       7         GetCursorPos(posall + i);
       8         printf("x=%d,y=%d
      ", (posall + i)->x, (posall + i)->y);
       9         Sleep(10);
      10     }
      11     //不断还原鼠标位置
      12     for (int i = 0; i < 1000; i++)
      13     {
      14         SetCursorPos((posall + i)->x, (posall + i)->y);
      15         printf("x=%d,y=%d
      ", (posall + i)->x, (posall + i)->y);
      16         Sleep(10);
      17     }
      18 }
    • 时间函数
       1 //时间函数
       2 void time_ts()
       3 {
       4     time_t now;
       5     //时间结构体
       6     struct tm *local, *gmt;
       7     //取得当前时间
       8     now = time(NULL);
       9     //时间
      10     printf("%d秒", now);
      11     //获取当前时间
      12     printf("
      此时此刻%s", ctime(&now));
      13     local = localtime(&now);
      14     //获取本地时间
      15     printf("
      本地时间%s", asctime(local));
      16     gmt = gmtime(&now);
      17     printf("
      格林威治时间%s", asctime(gmt));
      18     getchar();
      19 }

    完整代码

     1 #define _CRT_SECURE_NO_WARNINGS
     2 #include <stdio.h>
     3 #include <stdlib.h>
     4 #include <time.h>
     5 #include <Windows.h>
     6 
     7 POINT posall[1000];
     8 
     9 //备忘录模式
    10 void foget()
    11 {
    12     //不断获取鼠标位置
    13     for (int i = 0; i < 1000; i++)
    14     {
    15         GetCursorPos(posall + i);
    16         printf("x=%d,y=%d
    ", (posall + i)->x, (posall + i)->y);
    17         Sleep(10);
    18     }
    19     //不断还原鼠标位置
    20     for (int i = 0; i < 1000; i++)
    21     {
    22         SetCursorPos((posall + i)->x, (posall + i)->y);
    23         printf("x=%d,y=%d
    ", (posall + i)->x, (posall + i)->y);
    24         Sleep(10);
    25     }
    26 }
    27 
    28 //时间函数
    29 void time_ts()
    30 {
    31     time_t now;
    32     //时间结构体
    33     struct tm *local, *gmt;
    34     //取得当前时间
    35     now = time(NULL);
    36     //时间
    37     printf("%d秒", now);
    38     //获取当前时间
    39     printf("
    此时此刻%s", ctime(&now));
    40     local = localtime(&now);
    41     //获取本地时间
    42     printf("
    本地时间%s", asctime(local));
    43     gmt = gmtime(&now);
    44     printf("
    格林威治时间%s", asctime(gmt));
    45     getchar();
    46 }
    47 
    48 void main()
    49 {
    50     foget();
    51 }
  • 相关阅读:
    python自动化测试-使用第三方python库技术实现
    JMeter目录结构
    JMeter Http请求之content-type用法
    JMeter生成性能报表-Windows环境和Linux环境
    JMeter4.0 IF Controller
    c++ 初始化列表和构造函数初始化区别
    关于C++ 中 thread 的拷贝构造函数
    函数的参数类型 指针和指针的引用的区别
    window10 vs2013 SIFTGPU
    Qt使用双缓冲绘图时报错:pure virtual method called
  • 原文地址:https://www.cnblogs.com/xiaochi/p/8506832.html
Copyright © 2011-2022 走看看