首页 > 其他分享 >123

123

时间:2024-04-17 14:55:05浏览次数:27  
标签:week 123 set args time1 uint16 time

#include <stdio.h>
#include <stdint.h>

#pragma pack(push, 2)
typedef union {
    uint16_t all;
    struct {
        uint16_t time_set1 : 2;
        uint16_t time_set2 : 2;
        uint16_t time_set3 : 2;
        uint16_t time_set4 : 2;
        uint16_t time_set5 : 2;
        uint16_t time_set6 : 2;
        uint16_t time_set7 : 2;
        uint16_t time_set8 : 2;
    };
}time1_t;

typedef union {
    uint16_t all;
    struct {
        uint16_t time_set9 : 2;
        uint16_t time_set10 : 2;
    };
}time2_t;

typedef struct {
    union {
        uint16_t all;
        struct {
            uint16_t bitmap : 7;
            uint16_t onoff : 2;
        };
    } week_set;
    
    union {
        uint16_t all;
        struct {
            uint16_t min : 8;
            uint16_t hour : 8;
        };
    } time;
} time_args_t;
#pragma pack()

time_args_t time_args[10];
time1_t time1;
time2_t time2;

int main()
{
    time1.time_set1 = 1;
    time1.time_set2 = 1;
    time1.time_set3 = 1;
    time1.time_set4 = 1;
    time1.time_set5 = 1;
    time1.time_set6 = 1;
    time1.time_set7 = 1;
    time1.time_set8 = 1;
    time2.time_set9 = 1;
    time2.time_set10 = 1;
    printf("time1: 14704-%02x, time2: 14705-%02x\n", time1.all, time2.all);
    printf("x32-%02x%02x\n", time2.all, time1.all);
    
    time_args[0].week_set.bitmap = 0b0000001;
    time_args[0].week_set.onoff = 1;
    time_args[0].time.hour = 1;
    time_args[0].time.min = 30;
    
    time_args[1].week_set.bitmap = 0b0000010;
    time_args[1].week_set.onoff = 0;
    time_args[1].time.hour = 4;
    time_args[1].time.min = 40;
    
    time_args[2].week_set.bitmap = 0b0000100;
    time_args[2].week_set.onoff = 1;
    time_args[2].time.hour = 7;
    time_args[2].time.min = 5;
    
    time_args[3].week_set.bitmap = 0b0001000;
    time_args[3].week_set.onoff = 0;
    time_args[3].time.hour = 10;
    time_args[3].time.min = 45;
    
    time_args[4].week_set.bitmap = 0b0010000;
    time_args[4].week_set.onoff = 1;
    time_args[4].time.hour = 13;
    time_args[4].time.min = 12;
    
    time_args[5].week_set.bitmap = 0b0100000;
    time_args[5].week_set.onoff = 0;
    time_args[5].time.hour = 16;
    time_args[5].time.min = 15;
    
    time_args[6].week_set.bitmap = 0b1000000;
    time_args[6].week_set.onoff = 1;
    time_args[6].time.hour = 19;
    time_args[6].time.min = 32;
        
    time_args[7].week_set.bitmap = 0b0000100;
    time_args[7].week_set.onoff = 0;
    time_args[7].time.hour = 22;
    time_args[7].time.min = 54;
    
    time_args[8].week_set.bitmap = 0b0010000;
    time_args[8].week_set.onoff = 1;
    time_args[8].time.hour = 23;
    time_args[8].time.min = 22;
    
    time_args[9].week_set.bitmap = 0b1000000;
    time_args[9].week_set.onoff = 0;
    time_args[9].time.hour = 0;
    time_args[9].time.min = 0;
    
    int base = 14712;
    for (int i = 0; i < 10; i++)
    {
        printf("time arg[%d]: week: %d-%04x, time: %d-%04x\n", i, base, time_args[i].week_set.all, base+1, time_args[i].time.all);
        base += 2;
    }
    for (int i = 0; i < 10; i++)
    {
        printf("x32-%04x%04x,", time_args[i].time.all, time_args[i].week_set.all);
        if (i == 4) printf("\n");
    }
    
   return 0;
}

 

标签:week,123,set,args,time1,uint16,time
From: https://www.cnblogs.com/yeshenmeng/p/18140737

相关文章

  • 20212325
    123456......
  • 20212324
    第一部分第二部分?问题一问题二剩下......
  • Google Chrome 123 All In One
    GoogleChrome123AllInOnedevtoolseasteregg/复活节彩蛋寻找复活节彩蛋为了庆祝今年的愚人节,开发者工具团队在开发者工具的某个地方隐藏了一颗复活节彩蛋。要想找到它,请寻找色彩缤纷的......
  • SGM61230同步降压转换器
    这份文件是SGMicroCorp的SGM61230同步降压转换器的产品数据手册。以下是文件的核心内容概要:概述:SGM61230是一款由SGMicroCorp生产的同步降压转换器,设计用于在宽输入电压范围内提供高电流输出。以下是对该产品的详细概述:1.**输入电压范围**:-设备能够在4.5V至......
  • 123
    请阅读北航陈彦吉同学的这篇博客中(地址:https://www.cnblogs.com/ChildishChange/p/7363123.html)的各参考资料,并回答如下问题:1.回顾你过去将近3年的学习经历当初你报考的时候,是真正喜欢计算机这个专业吗?你现在后悔选择了这个专业吗?你认为你现在最喜欢的领域是什么(可以是计算机......
  • 1238 - 【入门】统计每个月兔子的总数
    题目描述有一对兔子,从出生后第3个月起每个月都生一对兔子,一对小兔子长到第三个月后每个月又生一对兔子,假如兔子都不死,问第n个月(n<=50)的兔子总数为多少对?输入:输入1个整数n,表示第几个月输出:第n个月兔子的总数量有多少对?样例:输入9输出34#include<bits/stdc++.h>usi......
  • 手把手教你用python一键抢12306火车票(附代码)
    哈喽,哈喽~,一年一度的抢火车票大战正式拉开序幕…然饿大多数人碰到的是这种情况:当你满心期待摩拳擦掌准备抢票的时候,你会发现一票难求!想回趟家真难!那么作为程序猿的你,当然要用程序猿的方式来抢票!下面分享用python来抢票!网站提供各种免费资源!城市cookie可根据具体需求自行添加!链......
  • 123
    正在设置aic8800d80fdrvpackage(0.0.3)...udevdonedevicenotexistcpfwdonex86_64make-C/lib/modules/6.5.0-26-generic/buildM=/usr/src/AIC8800/drivers/aic8800ARCH=x86_64CROSS_COMPILE=modulesmake[1]:警告:jobserver不可用:正使用-j1。添加“+”到父ma......
  • AcWing 1230. K倍区间 C++满分题解
    原题链接https://www.acwing.com/problem/content/1232/题目分析求区间和,我们可以通过前缀和来求出。我们规定sum[i]表示第1个元素到第i个元素的和。那么sum[r]-sum[l-1]就是区间[l,r]的和。一维前缀和for(inti=1;i<=n;i++){scanf("%lld",&sum[i]);......
  • 代码随想录算法训练营第五十天| ● 123.买卖股票的最佳时机III ● 188.买卖股票的
    买卖股票的最佳时机III  题目链接:123.买卖股票的最佳时机III-力扣(LeetCode)思路:与买卖股票2的区别在于我可以买卖两次,那么dp数组的状态就从两种变成了种,即第一次持有,第一次卖出,第二次持有,第二次卖出,注意这四种状态是不会同时存在的,除此之外还有一种状态,那就是不操作。if(......