编程打卡:C语言程序设计

Posted 松坂制糖厂

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了编程打卡:C语言程序设计相关的知识,希望对你有一定的参考价值。

class miband(Peripheral):
    _send_rnd_cmd = struct.pack(\'<2s\', b\'\\x02\\x00\')
    _send_enc_key = struct.pack(\'<2s\', b\'\\x03\\x00\')
    def __init__(self, mac_address,key=None, timeout=0.5, debug=False):
        FORMAT = \'%(asctime)-15s %(name)s (%(levelname)s) > %(message)s\'
        logging.basicConfig(format=FORMAT)
        log_level = logging.WARNING if not debug else logging.DEBUG
        self._log = logging.getLogger(self.__class__.__name__)
        self._log.setLevel(log_level)


        self._log.info(\'Connecting to \' + mac_address)
        Peripheral.__init__(self, mac_address, addrType=ADDR_TYPE_PUBLIC)
        self._log.info(\'Connected\')
        if not key:
            self.setSecurityLevel(level = "medium")
        self.timeout = timeout
        self.mac_address = mac_address
        self.state = None
        self.heart_measure_callback = None
        self.heart_raw_callback = None
        self.accel_raw_callback = None
        self.auth_key = key
        self.queue = Queue()
        self.svc_1 = self.getServiceByUUID(UUIDS.SERVICE_MIBAND1)
        self.svc_2 = self.getServiceByUUID(UUIDS.SERVICE_MIBAND2)
        self.svc_heart = self.getServiceByUUID(UUIDS.SERVICE_HEART_RATE)

        self._char_auth = self.svc_2.getCharacteristics(UUIDS.CHARACTERISTIC_AUTH)[0]
        self._desc_auth = self._char_auth.getDescriptors(forUUID=UUIDS.NOTIFICATION_DESCRIPTOR)[0]

        self._char_heart_ctrl = self.svc_heart.getCharacteristics(UUIDS.CHARACTERISTIC_HEART_RATE_CONTROL)[0]
        self._char_heart_measure = self.svc_heart.getCharacteristics(UUIDS.CHARACTERISTIC_HEART_RATE_MEASURE)[0]

        # Recorded information
        self._char_fetch = self.getCharacteristics(uuid=UUIDS.CHARACTERISTIC_FETCH)[0]
        self._desc_fetch = self._char_fetch.getDescriptors(forUUID=UUIDS.NOTIFICATION_DESCRIPTOR)[0]
        self._char_activity = self.getCharacteristics(uuid=UUIDS.CHARACTERISTIC_ACTIVITY_DATA)[0]
        self._desc_activity = self._char_activity.getDescriptors(forUUID=UUIDS.NOTIFICATION_DESCRIPTOR)[0]

        #chunked transfer and music
        self._char_chunked = self.svc_1.getCharacteristics(UUIDS.CHARACTERISTIC_CHUNKED_TRANSFER)[0]
        self._char_music_notif= self.svc_1.getCharacteristics(UUIDS.CHARACTERISTIC_MUSIC_NOTIFICATION)[0]
        self._desc_music_notif = self._char_music_notif.getDescriptors(forUUID=UUIDS.NOTIFICATION_DESCRIPTOR)[0]

        self._auth_notif(True)
        self.enable_music()
        self.activity_notif_enabled = False

        # set fallback callbacks before delegate starts
        self.init_empty_callbacks()

        # start delegate
        self.waitForNotifications(0.1)
        self.setDelegate( Delegate(self) )

    def init_empty_callbacks(self):
        def fallback():
            return
        self._default_music_play = fallback
        self._default_music_pause = fallback
        self._default_music_forward = fallback
        self._default_music_back = fallback
        self._default_music_vdown = fallback
        self._default_music_vup = fallback
        self._default_music_focus_in = fallback
        self._default_music_focus_out = fallback

        self._default_lost_device = fallback
        self._default_found_device = fallback

    def generateAuthKey(self):
        if(self.authKey):
            return struct.pack(\'<18s\',b\'\\x01\\x00\'+ self.auth_key)

    def _send_key(self):
        self._log.info("Sending Key...")
        self._char_auth.write(self._send_my_key)
        self.waitForNotifications(self.timeout)

    def _auth_notif(self, enabled):
        if enabled:
            self._log.info("Enabling Auth Service notifications status...")
            self._desc_auth.write(b"\\x01\\x00", True)
        elif not enabled:
            self._log.info("Disabling Auth Service notifications status...")
            self._desc_auth.write(b"\\x00\\x00", True)
        else:
            self._log.error("Something went wrong while changing the Auth Service notifications status...")

    def _auth_previews_data_notif(self, enabled):
        if enabled:
            self._log.info("Enabling Fetch Char notifications status...")
            self._desc_fetch.write(b"\\x01\\x00", True)
            self._log.info("Enabling Activity Char notifications status...")
            self._desc_activity.write(b"\\x01\\x00", True)
            self.activity_notif_enabled = True
        else:
            self._log.info("Disabling Fetch Char notifications status...")
            self._desc_fetch.write(b"\\x00\\x00", True)
            self._log.info("Disabling Activity Char notifications status...")
            self._desc_activity.write(b"\\x00\\x00", True)
            self.activity_notif_enabled = False

    def initialize(self):
        self._req_rdn()

        while True:
            self.waitForNotifications(0.1)
            if self.state == AUTH_STATES.AUTH_OK:
                self._log.info(\'Initialized\')
                self._auth_notif(False)
                return True
            elif self.state is None:
                continue

            self._log.error(self.state)
            return False

    def _req_rdn(self):
        self._log.info("Requesting random number...")
        self._char_auth.write(self._send_rnd_cmd)
        self.waitForNotifications(self.timeout)

    def _send_enc_rdn(self, data):
        self._log.info("Sending encrypted random number")
        cmd = self._send_enc_key + self._encrypt(data)
        send_cmd = struct.pack(\'<18s\', cmd)
        self._char_auth.write(send_cmd)
        self.waitForNotifications(self.timeout)

    def _encrypt(self, message):
        aes = AES.new(self.auth_key, AES.MODE_ECB)
        return aes.encrypt(message)

    def _get_from_queue(self, _type):
        try:
            res = self.queue.get(False)
        except Empty:
            return None
        if res[0] != _type:
            self.queue.put(res)
            return None
        return res[1]

    def _parse_queue(self):
        while True:
            try:
                res = self.queue.get(False)
                _type = res[0]
                if self.heart_measure_callback and _type == QUEUE_TYPES.HEART:
                    self.heart_measure_callback(struct.unpack(\'bb\', res[1])[1])
                elif self.heart_raw_callback and _type == QUEUE_TYPES.RAW_HEART:
                    self.heart_raw_callback(self._parse_raw_heart(res[1]))
                elif self.accel_raw_callback and _type == QUEUE_TYPES.RAW_ACCEL:
                    self.accel_raw_callback(self._parse_raw_accel(res[1]))
            except Empty:
                break

    def send_custom_alert(self, type, phone, msg):
        if type == 5:
            base_value = \'\\x05\\x01\'
        elif type == 4:
            base_value = \'\\x04\\x01\'
        elif type == 3:
                base_value = \'\\x03\\x01\'
        elif type == 1:
            base_value = \'\\x01\\x01\'
        svc = self.getServiceByUUID(UUIDS.SERVICE_ALERT_NOTIFICATION)
        char = svc.getCharacteristics(UUIDS.CHARACTERISTIC_CUSTOM_ALERT)[0]
        # 3 new lines: space for the icon, two spaces for the time HH:MM
        text = base_value+phone+\'\\x0a\\x0a\\x0a\'+msg.replace(\'\\\\n\',\'\\n\')
        char.write(bytes(text,\'utf-8\'), withResponse=True)

    def get_steps(self):
        char = self.svc_1.getCharacteristics(UUIDS.CHARACTERISTIC_STEPS)[0]
        a = char.read()
        steps = struct.unpack(\'h\', a[1:3])[0] if len(a) >= 3 else None
        meters = struct.unpack(\'h\', a[5:7])[0] if len(a) >= 7 else None
        fat_burned = struct.unpack(\'h\', a[2:4])[0] if len(a) >= 4 else None
        # why only 1 byte??
        calories = struct.unpack(\'b\', a[9:10])[0] if len(a) >= 10 else None
        return 
            "steps": steps,
            "meters": meters,
            "fat_burned": fat_burned,
            "calories": calories
        
    def _parse_raw_accel(self, bytes):
        res = []
        for i in xrange(3):
            g = struct.unpack(\'hhh\', bytes[2 + i * 6:8 + i * 6])
            res.append(\'x\': g[0], \'y\': g[1], \'wtf\': g[2])
        return res

    def _parse_raw_heart(self, bytes):
        res = struct.unpack(\'HHHHHHH\', bytes[2:])
        return res

    @staticmethod
    def _parse_date(bytes):
        year = struct.unpack(\'h\', bytes[0:2])[0] if len(bytes) >= 2 else None
        month = struct.unpack(\'b\', bytes[2:3])[0] if len(bytes) >= 3 else None
        day = struct.unpack(\'b\', bytes[3:4])[0] if len(bytes) >= 4 else None
        hours = struct.unpack(\'b\', bytes[4:5])[0] if len(bytes) >= 5 else None
        minutes = struct.unpack(\'b\', bytes[5:6])[0] if len(bytes) >= 6 else None
        seconds = struct.unpack(\'b\', bytes[6:7])[0] if len(bytes) >= 7 else None
        day_of_week = struct.unpack(\'b\', bytes[7:8])[0] if len(bytes) >= 8 else None
        fractions256 = struct.unpack(\'b\', bytes[8:9])[0] if len(bytes) >= 9 else None

        return "date": datetime(*(year, month, day, hours, minutes, seconds)), "day_of_week": day_of_week, "fractions256": fractions256

    @staticmethod
    def create_date_data(date):
        data = struct.pack( \'hbbbbbbbxx\', date.year, date.month, date.day, date.hour, date.minute, date.second, date.isoweekday(), 0 )
        return data

    def _parse_battery_response(self, bytes):
        level = struct.unpack(\'b\', bytes[1:2])[0] if len(bytes) >= 2 else None
        last_level = struct.unpack(\'b\', bytes[19:20])[0] if len(bytes) >= 20 else None
        status = \'normal\' if struct.unpack(\'b\', bytes[2:3])[0] == 0x0 else "charging"
        datetime_last_charge = self._parse_date(bytes[11:18])
        datetime_last_off = self._parse_date(bytes[3:10])

        res = 
            "status": status,
            "level": level,
            "last_level": last_level,
            "last_level": last_level,
            "last_charge": datetime_last_charge,
            "last_off": datetime_last_off
        
        return res

    def get_battery_info(self):
        char = self.svc_1.getCharacteristics(UUIDS.CHARACTERISTIC_BATTERY)[0]
        return self._parse_battery_response(char.read())

    def get_current_time(self):
        char = self.svc_1.getCharacteristics(UUIDS.CHARACTERISTIC_CURRENT_TIME)[0]
        return self._parse_date(char.read()[0:9])

    def get_revision(self):
        svc = self.getServiceByUUID(UUIDS.SERVICE_DEVICE_INFO)
        char = svc.getCharacteristics(UUIDS.CHARACTERISTIC_REVISION)[0]
        data = char.read()
        return data.decode(\'utf-8\')

    def get_hrdw_revision(self):
        svc = self.getServiceByUUID(UUIDS.SERVICE_DEVICE_INFO)
        char = svc.getCharacteristics(UUIDS.CHARACTERISTIC_HRDW_REVISION)[0]
        data = char.read()
        return data.decode(\'utf-8\')

    def set_encoding(self, encoding="en_US"):
        char = self.svc_1.getCharacteristics(UUIDS.CHARACTERISTIC_CONFIGURATION)[0]
        packet = struct.pack(\'5s\', encoding)
        packet = b\'\\x06\\x17\\x00\' + packet
        return char.write(packet)

    def set_heart_monitor_sleep_support(self, enabled=True, measure_minute_interval=1):
        char_m = self.svc_heart.getCharacteristics(UUIDS.CHARACTERISTIC_HEART_RATE_MEASURE)[0]
        char_d = char_m.getDescriptors(forUUID=UUIDS.NOTIFICATION_DESCRIPTOR)[0]
        char_d.write(b\'\\x01\\x00\', True)
        self._char_heart_ctrl.write(b\'\\x15\\x00\\x00\', True)
        # measure interval set to off
        self._char_heart_ctrl.write(b\'\\x14\\x00\', True)
        if enabled:
            self._char_heart_ctrl.write(b\'\\x15\\x00\\x01\', True)
            # measure interval set
            self._char_heart_ctrl.write(b\'\\x14\' + str(measure_minute_interval).encode(), True)
        char_d.write(b\'\\x00\\x00\', True)

    def _enable_fw_notification(self):
        svc = self.getServiceByUUID(UUIDS.SERVICE_DFU_FIRMWARE)
        char = svc.getCharacteristics(UUIDS.CHARACTERISTIC_DFU_FIRMWARE)[0]
        des = char.getDescriptors(forUUID = UUIDS.NOTIFICATION_DESCRIPTOR)[0]
        des.write(b"\\x01\\x00", True)

    def get_serial(self):
        svc = self.getServiceByUUID(UUIDS.SERVICE_DEVICE_INFO)
        char = svc.getCharacteristics(UUIDS.CHARACTERISTIC_SERIAL)[0]
        data = char.read()
        serial = struct.unpack(\'12s\', data[-12:])[0] if len(data) == 12 else None
        return serial.decode(\'utf-8\')

    def send_alert(self, _type):
        svc = self.getServiceByUUID(UUIDS.SERVICE_ALERT)
        char = svc.getCharacteristics(UUIDS.CHARACTERISTIC_ALERT)[0]
        char.write(_type)


    def set_current_time(self, date):
        char = self.svc_1.getCharacteristics(UUIDS.CHARACTERISTIC_CURRENT_TIME)[0]
        return char.write(self.create_date_data(date), True)

    def set_heart_monitor_sleep_support(self, enabled=True, measure_minute_interval=1):
        char_m = self.svc_heart.getCharacteristics(UUIDS.CHARACTERISTIC_HEART_RATE_MEASURE)[0]
        char_d = char_m.getDescriptors(forUUID=UUIDS.NOTIFICATION_DESCRIPTOR)[0]
        char_d.write(b\'\\x01\\x00\', True)
        self._char_heart_ctrl.write(b\'\\x15\\x00\\x00\', True)
        # measure interval set to off
        self._char_heart_ctrl.write(b\'\\x14\\x00\', True)
        if enabled:
            self._char_heart_ctrl.write(b\'\\x15\\x00\\x01\', True)
            # measure interval set
            self._char_heart_ctrl.write(b\'\\x14\' + str(measure_minute_interval).encode(), True)
        char_d.write(b\'\\x00\\x00\', True)

    def dfuUpdate(self,fileName):
        print(\'Update Watchface/Firmware\')
        svc = self.getServiceByUUID(UUIDS.SERVICE_DFU_FIRMWARE)
        char = svc.getCharacteristics(UUIDS.CHARACTERISTIC_DFU_FIRMWARE)[0]
        char_write = svc.getCharacteristics(UUIDS.CHARACTERISTIC_DFU_FIRMWARE_WRITE)[0]
        # self._enable_fw_notification()
        # self.setDelegate(TestDelegate(self))
        extension = os.path.splitext(fileName)[1][1:]
        fileSize = os.path.getsize(fileName)
        # calculating crc checksum of firmware
        #crc32
        crc=0xFFFF
        with open(fileName,"rb") as f:
            crc = zlib.crc32(f.read())
        print(\'CRC32 Value is-->\', crc)
        # input(\'Press Enter to Continue\')
        payload = b\'\\x01\\x08\'+struct.pack("<I",fileSize)[:-1]+b\'\\x00\'+struct.pack("<I",crc)
        char.write(payload,withResponse=True)
        self.waitForNotifications(2)
        char.write(b\'\\x03\\x01\',withResponse=True)
        with open(fileName,"rb") as f:
            while True:
                c = f.read(20) #takes 20 bytes 
                if not c:
                    print ("Bytes written successfully. Wait till sync finishes")
                    break
                char_write.write(c)
        # # after update is done send these values
        char.write(b\'\\x00\', withResponse=True)
        self.waitForNotifications(2)
        char.write(b\'\\x04\', withResponse=True)
        self.waitForNotifications(2)
        if extension.lower() == "fw":
            self.waitForNotifications(0.5)
            char.write(b\'\\x05\', withResponse=True)
        print(\'Update Complete\')
        input(\'Press Enter to Continue\')

    def get_heart_rate_one_time(self):
        # stop continous
        self._char_heart_ctrl.write(b\'\\x15\\x01\\x00\', True)
        # stop manual
        self._char_heart_ctrl.write(b\'\\x15\\x02\\x00\', True)
        # start manual
        self._char_heart_ctrl.write(b\'\\x15\\x02\\x01\', True)
        res = None
        while not res:
            self.waitForNotifications(self.timeout)
            res = self._get_from_queue(QUEUE_TYPES.HEART)

        rate = struct.unpack(\'bb\', res)[1]
        return rate

    def start_heart_rate_realtime(self, heart_measure_callback):
        char_m = self.svc_heart.getCharacteristics(UUIDS.CHARACTERISTIC_HEART_RATE_MEASURE)[0]
        char_d = char_m.getDescriptors(forUUID=UUIDS.NOTIFICATION_DESCRIPTOR)[0]
        char_ctrl = self.svc_heart.getCharacteristics(UUIDS.CHARACTERISTIC_HEART_RATE_CONTROL)[0]

        self.heart_measure_callback = heart_measure_callback

        # stop heart monitor continues & manual
        char_ctrl.write(b\'\\x15\\x02\\x00\', True)
        char_ctrl.write(b\'\\x15\\x01\\x00\', True)
        # enable heart monitor notifications
        char_d.write(b\'\\x01\\x00\', True)
        # start hear monitor continues
        char_ctrl.write(b\'\\x15\\x01\\x01\', True)
        t = time.time()
        while True:
            self.waitForNotifications(0.5)
            self._parse_queue()
            # send ping request every 12 sec
            if (time.time() - t) >= 12:
                char_ctrl.write(b\'\\x16\', True)
                t = time.time()


    def stop_realtime(self):
        char_m = self.svc_heart.getCharacteristics(UUIDS.CHARACTERISTIC_HEART_RATE_MEASURE)[0]
        char_d = char_m.getDescriptors(forUUID=UUIDS.NOTIFICATION_DESCRIPTOR)[0]
        char_ctrl = self.svc_heart.getCharacteristics(UUIDS.CHARACTERISTIC_HEART_RATE_CONTROL)[0]

        char_sensor1 = self.svc_1.getCharacteristics(UUIDS.CHARACTERISTIC_HZ)[0]
        char_sens_d1 = char_sensor1.getDescriptors(forUUID=UUIDS.NOTIFICATION_DESCRIPTOR)[0]

        char_sensor2 = self.svc_1.getCharacteristics(UUIDS.CHARACTERISTIC_SENSOR)[0]

        # stop heart monitor continues
        char_ctrl.write(b\'\\x15\\x01\\x00\', True)
        char_ctrl.write(b\'\\x15\\x01\\x00\', True)
        # IMO: stop heart monitor notifications
        char_d.write(b\'\\x00\\x00\', True)
        # WTF
        char_sensor2.write(b\'\\x03\')
        # IMO: stop notifications from sensors
        char_sens_d1.write(b\'\\x00\\x00\', True)

        self.heart_measure_callback = None
        self.heart_raw_callback = None
        self.accel_raw_callback = None

    def start_get_previews_data(self, start_timestamp):
        if not self.activity_notif_enabled:
            self._auth_previews_data_notif(True)
            self.waitForNotifications(0.1)
        print("Trigger activity communication")
        year = struct.pack("<H", start_timestamp.year)
        month = struct.pack("b", start_timestamp.month)
        day = struct.pack("b", start_timestamp.day)
        hour = struct.pack("b", start_timestamp.hour)
        minute = struct.pack("b", start_timestamp.minute)
        ts = year + month + day + hour + minute
        char = self.svc_1.getCharacteristics(UUIDS.CHARACTERISTIC_CURRENT_TIME)[0]
        utc_offset = char.read()[9:11]
        trigger = b\'\\x01\\x01\' + ts + utc_offset
        self._char_fetch.write(trigger, False)
        self.active = True
    
    def get_activity_betwn_intervals(self,start_timestamp, end_timestamp, callback ):
        self.end_timestamp = end_timestamp
        self.start_get_previews_data(start_timestamp)
        self.activity_callback = callback

    def enable_music(self):
        self._desc_music_notif.write(b\'\\x01\\x00\')

    def writeChunked(self,type,data):
        MAX_CHUNKLENGTH = 17
        remaining = len(data)
        count =0
        while(remaining > 0):
            copybytes = min(remaining,MAX_CHUNKLENGTH)
            chunk=b\'\'
            flag = 0
            if(remaining <= MAX_CHUNKLENGTH):
                flag |= 0x80
                if(count == 0):
                    flag |= 0x40
            elif(count>0):
                flag |= 0x40

            chunk+=b\'\\x00\'
            chunk+= bytes([flag|type])
            chunk+= bytes([count & 0xff])
            chunk+= data[(count * MAX_CHUNKLENGTH):(count * MAX_CHUNKLENGTH)+copybytes]
            count+=1
            self._char_chunked.write(chunk)
            remaining-=copybytes

    def writeDisplayCommand(self, cmd):
        \'\'\'Many display-related commands write to this endpoint.  This is a
        simple helper used by those function.\'\'\'

        char = self.svc_1.getCharacteristics(UUIDS.CHARACTERISTIC_CONFIGURATION)[0]
        endpoint = b\'\\x06\'
        char.write(endpoint + bytes(cmd))

    def setTrack(self, state, artist=None, album=None, track=None,
                 volume=None,
                 position=None, duration=None):
        self.pp_state = state
        self.artist = artist
        self.album = album
        self.track = track
        self.position = position
        self.duration = duration
        self.volume = volume
        self.setMusic()

    def setMusicCallback(self,play=None,pause=None,forward=None,backward=None,volumeup=None,volumedown=None,focusin=None,focusout=None):
        if play is not None:
            self._default_music_play = play
        if pause is not None:
            self._default_music_pause = pause
        if forward is not None:
            self._default_music_forward = forward
        if backward is not None:
            self._default_music_back = backward
        if volumedown is not None:
            self._default_music_vdown = volumedown
        if volumeup is not None:
            self._default_music_vup = volumeup
        if focusin is not None:
            self._default_music_focus_in = focusin
        if focusout is not None:
            self._default_music_focus_out = focusout

    def setLostDeviceCallback(self, lost=None, found=None):
        if lost is not None:
            self._default_lost_device = lost
        if found is not None:
            self._default_found_device = found

    def setAlarm(self, hour, minute, days=(), enabled=True, snooze=True,
                 alarm_id=0):
        \'\'\'Set an alarm at HOUR and MINUTE, on DAYS days.  Up to 3 alarms can be set.
        ENABLED can be used to remove an alarm.
        When SNOOZE is True, the alarm band will display a snooze button.\'\'\'
        char = self.svc_1.getCharacteristics(UUIDS.CHARACTERISTIC_CONFIGURATION)[0]

        alarm_tag = alarm_id
        if enabled:
            alarm_tag |= 0x80
            if not snooze:
                alarm_tag |= 0x40

        repetition_mask = 0x00
        for day in days:
            repetition_mask |= day

        packet = struct.pack("5B", 2, alarm_tag, hour, minute, repetition_mask)
        val = char.write(packet)
        return val

    def setMusic(self):
        flag = 0x00
        flag |= 0x01

        buf = b\'\'
        null = b\'\\x00\'
        if self.artist is not None:
            flag |= 0x02
            buf += self.artist.encode(\'utf-8\') + null
        if self.album is not None:
            flag |= 0x04
            buf += self.album.encode(\'utf-8\') + null
        if self.track is not None:
            flag |= 0x08
            buf += self.track.encode(\'utf-8\') + null
        if self.duration is not None:
            flag |= 0x10
            val = struct.pack(\'<H\', self.duration)
            buf += val
        if self.volume is not None:
            # volume goes from 0 to 100
            flag |= 0x40
            val = bytes([self.volume])
            buf += val + null

        if self.position is not None:
            position = struct.pack(\'<H\', self.position)
        else:
            position = null + null

        buf = bytes([flag, self.pp_state, 0x00]) + position + buf
        self.writeChunked(3, buf)

万人千题结对编程排位赛(第一期) 第二周 排名公布,冠军成功卫冕,啊这……

  博主会带领大家进行 《C语言入门100例》《算法零基础100讲》的训练,每天把一些知识点巩固后做完相应练习题,和群友一起打卡,如果身边有志同道合之人,也可一起加入,今天是打卡 第32天

今日社区打卡地址
《C语言入门100例》(第20例) 进制转换
《算法零基础100讲》(第32讲) 多维枚举(二) - 进阶

前言

  经过激烈的角逐,结对编程排位赛(第一期) 第二周 的排名已经出来了,观摩一下队员的风采吧!如果你也有和他们一样的热血,欢迎联系作者(微信:18368041307)加群,和他们一决高下吧!
   「 四个人 」 为一组,由队长带队刷题,每周根据这周(四个人)的 「 刷题总数 」 进行队伍间 「 排名 」。个人的总刷题数在总榜上,按照题数进行段位划分:「 宗师 」「 大师 」「 钻石 」「 白金 」「 黄金 」「 白银 」「 青铜 」。记录下每个人的 CSDN博客、LeetCode 主页,排名靠前的人可以得到更多的曝光。

🧡【万人千题】结对编程排位赛🧡

  如果想参加的「 第二期 」的同学,可以先联系作者加群,看看第一期的同袍是如何奋斗的。

一、结对编程排位赛(第一期) 第二周 排名

1、总榜

1)个人榜

1.1)冠军主页

   冠军,一周刷了 121 题(上周刷的是 138 题),卷王王中王本王,这是他的博客主页:解题者

1.2)亚军主页

  亚军,一周刷了 115 题,目前读研,绝对是一名种子选手,未来可期,三年之约我等你,这是他的博客主页:兴磊

1.3)季军主页

  季军,一周刷了 102 题,坚持了【万人千题计划】一个月,成功荣升 TOP3,坚持的力量大如天。这是他的博客主页:

2)组队榜

2.1)TOP1队伍

  队名:刷题王者,总共刷了 271 题。

队员题数
兴磊115
木木夕87
BhAem51
一切随缘~~~18

2.2)TOP2队伍

  队名:卷王一号,总共刷了 225 题。

队员题数
102
秋名山码民52
北辰天36
Siren35

2.3)TOP3队伍

  队名:零一coders,总共刷了 187 题。

队员题数
解题者121
代码yyds42
七元K21
励志码农趴趴3

2、个人榜TOP10

3、组队榜TOP10

二、激励机制

1、队伍奖励

  TOP2 的队伍中刷题数最多者 解题者兴磊,请尽快联系作者,提供 姓名、手机号、收货地址。奖励只是激励手段,相信各位也不会在乎这点奖励,刷题要养成爱好才能可持续发展。


【内容简介】
  《Python机器学习一本通》结合了Python和机器学习两个热门领域,通过易于理解的知识讲解,帮助读者学习和掌握机器学习。
  全书共20章,分为5篇。其中1篇为基础入门篇,主要讲述Python机器学习入门、设置机器学习的环境、机器学习基础和统计分析数学基础等内容;第2篇为数据预处理篇,主要讲述了产生和加载数据集、数据预处理等内容;第3篇为机器学习算法篇,主要讲述了回归分析、决策树分析、支持向量机、聚类分析、集成学习、神经网络学习、卷积网络学习和模型评价等内容;第4篇为机器学习应用篇,主要讲述了图像识别、语音识别、期刊新闻分类和图形压缩4个机器学习应用;第5篇为项目实战篇,主要讲述了社交好友分析、电商点击率预估等。
  本书适用于想了解传统机器学习算法的学生和从业者,想知道如何高效实现机器学习算法的程序员,以及想了解机器学习算法能如何进行应用的职员、经理等。

【作者简介】
  杨志晓,工学博士,副教授,现在河南牧业经济学院智能制造与自动化学院工作,从事计算机应用、控制理论与控制工程专业的教学与科研工作。研究方向主要有:人工智能理论及应用、人机情感交互、可信计算。
  曾参与主持河南省重点科技攻关项目1项、河南省教育厅自然科学研究计划项目2项、河南省高校青年骨干教师资助计划项目、郑州市科技攻关项目各1项,主持省级鉴定项目5项,作为主要完成人参与省级项目10余项,参与国家“十一五”科技支撑计划项目1项,获省政府科技进步2等奖和3等奖各1项,获教育厅科技成果一等奖2项,二等奖4项。获国家授权发明专利2项(均为主持)等。
  范艳峰,工学博士,教授。1995年至今,于河南工业大学信息科学与工程学院工作,教授。从事人工智能理论及应用的教学科研工作。
  京东自营购买链接:链接
  当当自营购买链接:链接

2、社区活跃奖励

1)每日打卡

  积极参加 万人千题 社区,C语言每日打卡算法零基础每日打卡结对编程排位赛,踊跃写解题报告,给文章点赞、回复,获得积分参与每周积分排名,就有机会获得 CSDN 官方定制礼品。

2)本周排名

2.1)排名1 - 10 名

   周一公布

2.2)排名11 - 15 名

   周一公布

2.3)排名16 - 30 名

   周一公布

三、第三周的计划

  结对编程排位赛(第一期) 第三周 的 集训计划,从明天(2021.11.22)开始,会对队伍进行一定的调整,没有晋级的队伍将退出本群,晋级这个事情我不想很强制说一定要淘汰,只是末尾的队友,如果自己觉得会拖累队友,是可以退出的,然后队伍也是可以重组的。排位的目的不是为了卷死大家,而是为了共同成长。
  规则会进行如下几个调整:
  1)严格按照上周刷题数进行组队分配,【三强一弱】的形式进行组队,三带一,必定起飞!
  2)由于临近期末考试,暂时退赛的选手可以私聊我退赛;
  3)2021.11.21日19:00 前报名结束;

四、巾帼不让须眉

  ACM金牌、世界总决赛选手,七日速成法(秘),无论你的过去怎样,现在如何,将来的你势必神挡杀神,佛挡杀佛!目前招收 72 位 关门女弟子, 剩余 0 个名额,队长亲手带教,魔鬼式训练法,打造 万人千题 巾帼不让须眉 团队,让不甘平庸的你,艳杀四方,不虚此行。

五、明年今日

  由于【付费专栏】购买后,只有一年的阅读权限,很多用户反馈不知道,为了维护消费者的利益,回馈广大用户,作者打算将付费文章制作成 pdf,并且在 【明年今日】(2022.11.11日) 将 一年内过期的文章通过文件的形式开放出来。
  由于制作过程会比较繁琐,而且需要各种的查错纠正,较为烧脑,具体细则如下:

【用户范围】今日购买的付费专栏的用户直接享有对应的专栏精装版 pdf(在这之前,已经购买过对应付费专栏需要添加作者后提供凭据);
【专栏范围】《C语言入门100例》《算法零基础100讲》《画解数据结构》《夜深人静写算法》
【索要优惠】需要优惠券的,本文开头链接,今日双十一特惠已开放获取,每日 99 张,赠完为止。

六、三年之约

  作者在此承诺!只要你不舍,我不弃,你我同心协力,以三年为期,引万人之势气,共筑未来美好三年!三年之后,算法刷满 1000 题,你我字节见,你不来,我不走!

七、粉丝专属福利

语言入门《光天化日学C语言》(示例代码)
语言训练《C语言入门100例》试用版
数据结构《画解数据结构》源码
算法入门《算法入门》指引
算法进阶《夜深人静写算法》算法模板

  

👇🏻 验证码 可通过下方 公众号 获取👇🏻

以上是关于编程打卡:C语言程序设计的主要内容,如果未能解决你的问题,请参考以下文章

打卡 c语言趣味编程 求勾股数

编程打卡: C++ 语言程序设计

编程打卡: C++ 语言程序设计: 继承与派生: 习题

编程打卡:C++语言程序设计

从初始C语言到算法必须经历的过程,没有捷径?

万人千题结对编程排位赛 (第一期) 火爆开启