char_out.c

C语言字符输出示例

  name="google_ads_frame" marginwidth="0" marginheight="0" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-5572165936844014&dt=1194442938015&lmt=1194190197&format=336x280_as&output=html&correlator=1194442937843&url=file%3A%2F%2F%2FC%3A%2FDocuments%2520and%2520Settings%2Flhh1%2F%E6%A1%8C%E9%9D%A2%2FCLanguage.htm&color_bg=FFFFFF&color_text=000000&color_link=000000&color_url=FFFFFF&color_border=FFFFFF&ad_type=text&ga_vid=583001034.1194442938&ga_sid=1194442938&ga_hid=1942779085&flash=9&u_h=768&u_w=1024&u_ah=740&u_aw=1024&u_cd=32&u_tz=480&u_java=true" frameborder="0" width="336" scrolling="no" height="280" allowtransparency="allowtransparency"> #include <stdio.h>

void main(void)
 {
   printf("The letter is %c/n", 'A');
   printf("The letter is %c/n", 65);
 }

 

general_camera_manage.c:768:8: error: 'response' redeclared as different kind of symbol char *response = NULL; ^ general_camera_manage.c:758:109: note: previous definition of 'response' was here bool udsd_get_response_to_camera(struct udsd_camera_session *session, unsigned char *http_body, const char *response) ^ In file included from ../../udsd_session.h:7:0, from ../../udsd.h:10, from general_camera_manage.c:16: general_camera_manage.c:792:87: error: 'b_tmp' undeclared (first use in this function) config_passwd = blobuci_get(account, account, general_password, blobmsg_get_string, &b_tmp); ^ general_camera_manage.c:792:87: note: each undeclared identifier is reported only once for each function it appears in general_camera_manage.c:820:111: error: pointer targets in passing argument 5 of 'aes_cbc_128_decrypt' differ in signedness [-Werror=pointer-sign] aes_cbc_128_decrypt((unsigned char *)response_aes_dec, dec_len, (unsigned char *)response_aes_dec, buf_size, aes_lsk, aes_ivb); ^ In file included from general_camera_manage.c:18:0: ../../udsd_auth.h:156:5: note: expected 'unsigned char *' but argument is of type 'char *' int aes_cbc_128_decrypt(unsigned char *in, size_t ilen, unsigned char *out, size_t olen, unsigned char *iv, unsigned char *key); ^ general_camera_manage.c:820:120: error: pointer targets in passing argument 6 of 'aes_cbc_128_decrypt' differ in signedness [-Werror=pointer-sign] aes_cbc_128_decrypt((unsigned char *)response_aes_dec, dec_len, (unsigned char *)response_aes_dec, buf_size, aes_lsk, aes_ivb); ^ In file included from general_camera_manage.c:18:0: ../../udsd_auth.h:156:5: note: expected 'unsigned char *' but argument is of type 'char *' int aes_cbc_128_decrypt(unsigned char *in, size_t ilen, unsigned char *out, size_t olen, unsigned char *iv, unsigned char *key); ^ general_camera_manage.c:824:40: error: 'out' undeclared (first use in this function) blobmsg_add_json_from_string_with_len(out, response_aes_dec, strlen(response_aes_dec), true); ^ cc1: all warnings being treated as errors
10-29
内容概要:本文详细介绍了“秒杀商城”微服务架构的设计与实战全过程,涵盖系统从需求分析、服务拆分、技术选型到核心功能开发、分布式事务处理、容器化部署及监控链路追踪的完整流程。重点解决了高并发场景下的超卖问题,采用Redis预减库存、消息队列削峰、数据库乐观锁等手段保障数据一致性,并通过Nacos实现服务注册发现与配置管理,利用Seata处理跨服务分布式事务,结合RabbitMQ实现异步下单,提升系统吞吐能力。同时,项目支持Docker Compose快速部署和Kubernetes生产级编排,集成Sleuth+Zipkin链路追踪与Prometheus+Grafana监控体系,构建可观测性强的微服务系统。; 适合人群:具备Java基础和Spring Boot开发经验,熟悉微服务基本概念的中高级研发人员,尤其是希望深入理解高并发系统设计、分布式事务、服务治理等核心技术的开发者;适合工作2-5年、有志于转型微服务或提升架构能力的工程师; 使用场景及目标:①学习如何基于Spring Cloud Alibaba构建完整的微服务项目;②掌握秒杀场景下高并发、超卖控制、异步化、削峰填谷等关键技术方案;③实践分布式事务(Seata)、服务熔断降级、链路追踪、统一配置中心等企业级中间件的应用;④完成从本地开发到容器化部署的全流程落地; 阅读建议:建议按照文档提供的七个阶段循序渐进地动手实践,重点关注秒杀流程设计、服务间通信机制、分布式事务实现和系统性能优化部分,结合代码调试与监控工具深入理解各组件协作原理,真正掌握高并发微服务系统的构建能力。
package hk.gov.housingauthority.nco.cmp.common.captcha; import javax.sound.sampled.*; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.Base64; import java.util.HashMap; import java.util.Map; public class AudioCaptchaGenerator { private static final int SAMPLE_RATE = 44100; private static final int DURATION_MS_PER_CHAR = 500; private static final int SILENCE_MS = 100; private static final int BASE_FREQ = 220; private static final Map<Character, int[]> CHAR_TO_FORMANTS = new HashMap<>(); static { CHAR_TO_FORMANTS.put('0', new int[]{ 220, 400, 1000 }); // "Zero" CHAR_TO_FORMANTS.put('1', new int[]{ 220, 500, 1500 }); // "One" CHAR_TO_FORMANTS.put('2', new int[]{ 220, 600, 1800 }); // "Two" CHAR_TO_FORMANTS.put('3', new int[]{ 220, 550, 2000 }); // "Three" CHAR_TO_FORMANTS.put('4', new int[]{ 220, 700, 1600 }); // "Four" CHAR_TO_FORMANTS.put('5', new int[]{ 220, 650, 1900 }); // "Five" CHAR_TO_FORMANTS.put('6', new int[]{ 220, 750, 1700 }); // "Six" CHAR_TO_FORMANTS.put('7', new int[]{ 220, 800, 2200 }); // "Seven" CHAR_TO_FORMANTS.put('8', new int[]{ 220, 500, 1400 }); // "Eight" CHAR_TO_FORMANTS.put('9', new int[]{ 220, 600, 2100 }); // "Nine" CHAR_TO_FORMANTS.put('A', new int[]{ 220, 800, 1200 }); // "Ah"(如 "Father") CHAR_TO_FORMANTS.put('E', new int[]{ 220, 500, 2300 }); // "Eh"(如 "Bed") CHAR_TO_FORMANTS.put('I', new int[]{ 220, 300, 2500 }); // "Ee"(如 "See") CHAR_TO_FORMANTS.put('O', new int[]{ 220, 500, 800 }); // "Oh"(如 "Boat") CHAR_TO_FORMANTS.put('U', new int[]{ 220, 300, 700 }); // "Oo"(如 "Boot") CHAR_TO_FORMANTS.put('B', new int[]{ 220, 400, 2000 }); // "Buh"(爆破音) CHAR_TO_FORMANTS.put('C', new int[]{ 220, 500, 1800 }); // "Kuh"(硬颚音) CHAR_TO_FORMANTS.put('D', new int[]{ 220, 300, 2200 }); // "Duh" CHAR_TO_FORMANTS.put('F', new int[]{ 220, 400, 1700 }); // "Fuh"(摩擦音) CHAR_TO_FORMANTS.put('G', new int[]{ 220, 300, 1900 }); // "Guh" CHAR_TO_FORMANTS.put('H', new int[]{ 220, 1000, 1200 }); // "Huh"(气流音) CHAR_TO_FORMANTS.put('J', new int[]{ 220, 600, 2400 }); // "Juh"(如 "Jump") CHAR_TO_FORMANTS.put('K', new int[]{ 220, 800, 1800 }); // "Kuh" CHAR_TO_FORMANTS.put('L', new int[]{ 220, 400, 1500 }); // "Luh"(舌侧音) CHAR_TO_FORMANTS.put('M', new int[]{ 220, 200, 1000 }); // "Mmm"(鼻音) CHAR_TO_FORMANTS.put('N', new int[]{ 220, 300, 1200 }); // "Nnn"(鼻音) CHAR_TO_FORMANTS.put('P', new int[]{ 220, 500, 2000 }); // "Puh" CHAR_TO_FORMANTS.put('Q', new int[]{ 220, 700, 1600 }); // "Kuh"(如 "Queen") CHAR_TO_FORMANTS.put('R', new int[]{ 220, 600, 1400 }); // "Rrr"(卷舌音) CHAR_TO_FORMANTS.put('S', new int[]{ 220, 5000, 6000 }); // "Sss"(高频摩擦音) CHAR_TO_FORMANTS.put('T', new int[]{ 220, 400, 1800 }); // "Tuh" CHAR_TO_FORMANTS.put('V', new int[]{ 220, 300, 1600 }); // "Vuh" CHAR_TO_FORMANTS.put('W', new int[]{ 220, 200, 800 }); // "Wuh"(圆唇音) CHAR_TO_FORMANTS.put('X', new int[]{ 220, 700, 2200 }); // "Ks"(如 "Box") CHAR_TO_FORMANTS.put('Y', new int[]{ 220, 400, 1200 }); // "Yuh"(如 "Yes") CHAR_TO_FORMANTS.put('Z', new int[]{ 220, 4500, 5500 }); // "Zzz"(高频摩擦音) } public static byte[] generateCaptchaAudio(String text) { try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { AudioFormat format = new AudioFormat(SAMPLE_RATE, 16, 1, true, false); for (char c : text.toUpperCase().toCharArray()) { int[] formants = CHAR_TO_FORMANTS.getOrDefault(c, new int[]{ BASE_FREQ }); addVowelSound(baos, format, formants, DURATION_MS_PER_CHAR); addSilence(baos, format, SILENCE_MS); } return convertToWav(baos.toByteArray(), format); } catch (IOException e) { throw new RuntimeException("Failed to generate audio captcha", e); } } private static void addVowelSound( ByteArrayOutputStream baos, AudioFormat format, int[] formants, int durationMs ) throws IOException { byte[] buffer = new byte[format.getFrameSize() * (int)(format.getSampleRate() * durationMs / 1000)]; for (int i = 0; i < buffer.length; i += 2) { double sample = 0; // 叠加共振峰频率 for (int j = 0; j < formants.length; j++) { double freq = formants[j]; double volume = 1.0 / (j + 1); // 高频衰减 double angle = 2.0 * Math.PI * freq * (i / 2) / format.getSampleRate(); sample += volume * Math.sin(angle); } // 应用包络(ADSR) double envelope = calculateEnvelope(i, buffer.length); short sampleValue = (short)(Short.MAX_VALUE * sample * envelope * 0.8); // 避免削波 buffer[i] = (byte)(sampleValue & 0xFF); buffer[i + 1] = (byte)((sampleValue >> 8) & 0xFF); } baos.write(buffer); } private static double calculateEnvelope(int currentPos, int totalLength) { double attack = 0.1; // 10% 攻击时间 double release = 0.3; // 30% 释放时间 if (currentPos < attack * totalLength) { return currentPos / (attack * totalLength); // 渐强 } else if (currentPos > (1 - release) * totalLength) { return 1 - (currentPos - (1 - release) * totalLength) / (release * totalLength); // 渐弱 } else { return 1.0; // 持续 } } public static String generateCaptchaAudioAsBase64(String text) { try { byte[] wavData = generateCaptchaAudio(text); return Base64.getEncoder().encodeToString(wavData); } catch (Exception e) { throw new RuntimeException("Failed to generate audio captcha", e); } } private static byte[] convertToWav(byte[] audioData, AudioFormat format) throws IOException { try (ByteArrayOutputStream wavOutputStream = new ByteArrayOutputStream()) { // WAV文件頭 wavOutputStream.write("RIFF".getBytes()); writeInt(wavOutputStream, 36 + audioData.length); // 文件總長度 wavOutputStream.write("WAVE".getBytes()); wavOutputStream.write("fmt ".getBytes()); writeInt(wavOutputStream, 16); // fmt塊長度 writeShort(wavOutputStream, (short) 1); // 音頻格式 (PCM) writeShort(wavOutputStream, (short) format.getChannels()); writeInt(wavOutputStream, (int) format.getSampleRate()); writeInt(wavOutputStream, (int) (format.getSampleRate() * format.getFrameSize())); writeShort(wavOutputStream, (short) format.getFrameSize()); writeShort(wavOutputStream, (short) format.getSampleSizeInBits()); wavOutputStream.write("data".getBytes()); writeInt(wavOutputStream, audioData.length); wavOutputStream.write(audioData); return wavOutputStream.toByteArray(); } } private static void writeInt(ByteArrayOutputStream out, int value) throws IOException { out.write(value); out.write(value >> 8); out.write(value >> 16); out.write(value >> 24); } private static void writeShort(ByteArrayOutputStream out, short value) throws IOException { out.write(value); out.write(value >> 8); } private static void addSilence(ByteArrayOutputStream baos, AudioFormat format, int durationMs) throws IOException { byte[] buffer = new byte[format.getFrameSize() * (int) (format.getSampleRate() * durationMs / 1000)]; baos.write(buffer); } } 加入BASE 65 對應的CHAR_TO_FORMANTS
07-17
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值