Write an application Output10Times

Paper test in interview:

Use below functions to finish a function that multiply one integer 10 times.

  • Console.WriteLine()
  • Console,ReadKey()
  • String.Format()
  • Int32.TryParse()

To show result like:

Please input an integer:

good!

Please input an integer:

6.4313

Please input an integer:

67

0 * 67 =0
1 * 67 =67
2 * 67 =134
3 * 67 =201
4 * 67 =268
5 * 67 =335
6 * 67 =402
7 * 67 =469
8 * 67 =536
9 * 67 =603

=================================================================================================

public void Output10Times()

{

    int n = 0;
BEGIN:
    Console.WriteLine("Please input an integer:");
    if (Int32.TryParse(Console.ReadLine(), out n))
    {
    for (int i = 0; i < 10; i++)
        Console.WriteLine(String.Format("{0} * {1} ={2}", i, n, i * n));
    return;
    }
    goto BEGIN;

}

New Bitmap Image

转载于:https://www.cnblogs.com/diggingdeeply/archive/2010/12/07/Write_an_application_Output10Times.html

11.2.1 Power Up (and after a software generated register reset) Procedure Guidance Turn on external power supplies and wait for supply voltages to settle. This amount of time will be dependent on the system design. Software may choose to test the NAU88C22 to determine when it is no longer in an active reset condition. This procedure is described in more detail in the sections relating to power supplies. If the VDDSPK supply voltage is 3.60V or less, the next step should be to configure all of the output registers for low voltage operation. This sets the internal DC levels and gains to optimal levels for operation at lower voltages. Register settings required for this are: R49 Bit 2, SPKBST; Bit 3, AUX2BST; Bit 4, AUX1BST, set to logic = 0 As a general policy, it is a good idea to put any input or output driver paths into the “mute” condition any time internal register and data path configurations are being changed. Be sure at this time that all used inputs and outputs are in their muted/disconnected condition. Next, the internal DC tie-off voltage buffers should be enabled: R1 Bit 2, IOBUFEN, set to logic = 1 R1 Bit 8, DCBUFEN, set to logic = 1 if setting up for greater than 3.60V operation Value to be written to R1 = 0x104 At this point, the NAU88C22 has been prepared to start charging any input/output capacitors to their normal operating mode charge state. If this is done slowly, then there will be no pops and clicks. One way to accomplish this is to allow the internal/external reference voltage to charge slowly by means of its internal coupling resistors. This is accomplished by: R1 Bits 1, Bit 0, REFIMP set to 80kΩ setting R1 Bit 2, ABIASEN, set to logic = 1 Value to be written to R1 = 0x10D After this, the system should wait approximately 250ms, or longer, depending on the external components that have been selected for a given specific application. After this, outputs may be enabled, but with the drivers still in the mute condition. Unless power management requires outputs to be turned off when not used, it is best for pops and clicks to leave outputs enabled at all times, and to use the output mute controls to silence the outputs as needed. Next, the NAU88C22 can be programmed as needed for a specific application. The final step in most applications will be to unmute any outputs, and then begin normal operation. 以上上电控制的逻辑请解释
05-28
@ApiOperation("批量下载图像及label文件成压缩包接口") @PostMapping("/downloadZip") public DeferredResult<ResponseEntity<StreamingResponseBody>> downloadZip(@RequestBody List<Long> ids) { DeferredResult<ResponseEntity<StreamingResponseBody>> deferredResult = new DeferredResult<>(3600000L); CompletableFuture.runAsync(() -> { try { // 提前校验数据 List<CpImageInfo> cpImageInfos = cpImageMapper.selectBatchIds(ids); if (cpImageInfos.isEmpty()) { throw new RuntimeException("未找到样本信息"); } String zipName = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".zip"; HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); headers.setContentDisposition(ContentDisposition.builder("attachment") .filename(URLEncoder.encode(zipName, "UTF-8")).build()); // 使用匿名内部类 StreamingResponseBody stream = new StreamingResponseBody() { @Override public void writeTo(OutputStream outputStream) throws IOException { try { fileImageService.downloadZip(ids, outputStream); } catch (Exception e) { log.error("文件流生成异常", e); throw new IOException("压缩过程发生错误"); } } }; deferredResult.setResult(ResponseEntity.ok() .headers(headers) .body(stream)); } catch (Exception e) { deferredResult.setErrorResult( ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) .body("下载失败: " + e.getMessage())); } }); deferredResult.onTimeout(() -> deferredResult.setErrorResult( ResponseEntity.status(HttpStatus.REQUEST_TIMEOUT) .body("下载超时"))); deferredResult.onError(ex -> deferredResult.setErrorResult( ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) .body("系统错误: " + ex.getMessage()))); return deferredResult; } @Override public void downloadZip(List<Long> ids, OutputStream outputStream) throws IOException { List<CpImageInfo> cpImageInfos = cpImageMapper.selectBatchIds(ids); if (cpImageInfos.isEmpty()) { throw new RuntimeException("未找到样本信息"); } // 使用非缓冲流提高大文件性能 try (ZipOutputStream zos = new ZipOutputStream(outputStream)) { zos.setLevel(Deflater.DEFAULT_COMPRESSION); // 平衡速度和压缩率 String rootDir = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + "/"; int i = 0; for (CpImageInfo imageInfo : cpImageInfos) { if (Thread.currentThread().isInterrupted()) { throw new IOException("下载被中断"); } i++; String safeImageName = sanitizeFilename(imageInfo.getImageName()); String name = removeParentheses(safeImageName); String sampleDir = rootDir + name + "(" + i + ")/"; // 处理图像文件 List<CpImageBasicInfo> imageFiles = cpImageBasicMapper.selectByUniqueValue(imageInfo.getUniqueValue()); for (CpImageBasicInfo file : imageFiles) { addFileToZip(zos, sampleDir + "img/" + file.getImageName(), file.getImagePath()); } // 处理标签文件 List<CpLabelBasicInfo> labelFiles = cpLabelBasicMapper.selectByUniqueValue(imageInfo.getUniqueValue()); for (CpLabelBasicInfo file : labelFiles) { addFileToZip(zos, sampleDir + "gt/" + file.getLabelFileName(), file.getLabelFilePath()); } // 定期刷新输出流 zos.flush(); outputStream.flush(); } } } // 改进的文件添加方法 private void addFileToZip(ZipOutputStream zos, String entryName, String filePath) throws IOException { File file = new File(filePath); if (!file.exists()) { log.warn("文件不存在: {}", filePath); return; } try (FileInputStream fis = new FileInputStream(file)) { ZipEntry zipEntry = new ZipEntry(entryName); zos.putNextEntry(zipEntry); byte[] buffer = new byte[65536]; // 64KB 缓冲区 int len; while ((len = fis.read(buffer)) > 0) { // 检查是否中断 if (Thread.currentThread().isInterrupted()) { throw new IOException("下载被中断"); } zos.write(buffer, 0, len); } zos.closeEntry(); } } // 文件名消毒处理 private String sanitizeFilename(String filename) { return filename.replaceAll("[\\\\/:*?\"<>|]", "_"); } public String removeParentheses(String filename) { if (filename == null) { return null; } String result = filename; int prevLength; // 循环替换直到没有括号内容 do { prevLength = result.length(); result = result.replaceAll("\\(.*?\\)", ""); } while (result.length() < prevLength); return result; } 2025-06-06 10:56:59.176 ERROR 22432 --- [ MvcAsync1] c.a.e.c.sample.FileImageController : 文件流生成异常 org.apache.catalina.connector.ClientAbortException: java.io.IOException: 远程主机强迫关闭了一个现有的连接。 at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:353) ~[tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.catalina.connector.OutputBuffer.flushByteBuffer(OutputBuffer.java:783) ~[tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.catalina.connector.OutputBuffer.append(OutputBuffer.java:688) ~[tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:388) ~[tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:366) ~[tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:96) ~[tomcat-embed-core-9.0.63.jar:9.0.63] at java.util.zip.DeflaterOutputStream.deflate(DeflaterOutputStream.java:253) ~[na:1.8.0_102] at java.util.zip.DeflaterOutputStream.write(DeflaterOutputStream.java:211) ~[na:1.8.0_102] at java.util.zip.ZipOutputStream.write(ZipOutputStream.java:331) ~[na:1.8.0_102] at com.aircas.evaluation.service.impl.sample.FileImageInfoServiceImpl.addFileToZip(FileImageInfoServiceImpl.java:876) ~[classes/:na] at com.aircas.evaluation.service.impl.sample.FileImageInfoServiceImpl.downloadZip(FileImageInfoServiceImpl.java:841) ~[classes/:na] at com.aircas.evaluation.service.impl.sample.FileImageInfoServiceImpl$$FastClassBySpringCGLIB$$50be5633.invoke(<generated>) ~[classes/:na] at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.3.20.jar:5.3.20] at org.springframework.aop.framework.CglibAopProxy.invokeMethod(CglibAopProxy.java:386) ~[spring-aop-5.3.20.jar:5.3.20] at org.springframework.aop.framework.CglibAopProxy.access$000(CglibAopProxy.java:85) ~[spring-aop-5.3.20.jar:5.3.20] at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:704) ~[spring-aop-5.3.20.jar:5.3.20] at com.aircas.evaluation.service.impl.sample.FileImageInfoServiceImpl$$EnhancerBySpringCGLIB$$5e579eb.downloadZip(<generated>) ~[classes/:na] at com.aircas.evaluation.controller.sample.FileImageController$1.writeTo(FileImageController.java:315) ~[classes/:na] at org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBodyReturnValueHandler$StreamingResponseBodyTask.call(StreamingResponseBodyReturnValueHandler.java:111) [spring-webmvc-5.3.20.jar:5.3.20] at org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBodyReturnValueHandler$StreamingResponseBodyTask.call(StreamingResponseBodyReturnValueHandler.java:98) [spring-webmvc-5.3.20.jar:5.3.20] at org.springframework.web.context.request.async.WebAsyncManager.lambda$startCallableProcessing$4(WebAsyncManager.java:337) [spring-web-5.3.20.jar:5.3.20] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[na:1.8.0_102] at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266) ~[na:1.8.0_102] at java.util.concurrent.FutureTask.run(FutureTask.java) ~[na:1.8.0_102] at java.lang.Thread.run(Thread.java:745) ~[na:1.8.0_102] Suppressed: org.apache.catalina.connector.ClientAbortException: java.io.IOException: The current thread was interrupted at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:353) ~[tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.catalina.connector.OutputBuffer.flushByteBuffer(OutputBuffer.java:783) ~[tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.catalina.connector.OutputBuffer.append(OutputBuffer.java:688) ~[tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:388) ~[tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:366) ~[tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:96) ~[tomcat-embed-core-9.0.63.jar:9.0.63] at java.util.zip.DeflaterOutputStream.deflate(DeflaterOutputStream.java:253) ~[na:1.8.0_102] at java.util.zip.ZipOutputStream.closeEntry(ZipOutputStream.java:255) ~[na:1.8.0_102] at java.util.zip.ZipOutputStream.finish(ZipOutputStream.java:360) ~[na:1.8.0_102] at java.util.zip.DeflaterOutputStream.close(DeflaterOutputStream.java:238) ~[na:1.8.0_102] at java.util.zip.ZipOutputStream.close(ZipOutputStream.java:377) ~[na:1.8.0_102] at com.aircas.evaluation.service.impl.sample.FileImageInfoServiceImpl.downloadZip(FileImageInfoServiceImpl.java:854) ~[classes/:na] ... 14 common frames omitted Caused by: java.io.IOException: The current thread was interrupted at org.apache.tomcat.util.net.NioChannel.checkInterruptStatus(NioChannel.java:236) at org.apache.tomcat.util.net.NioChannel.write(NioChannel.java:134) at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.doWrite(NioEndpoint.java:1384) at org.apache.tomcat.util.net.SocketWrapperBase.doWrite(SocketWrapperBase.java:773) at org.apache.tomcat.util.net.SocketWrapperBase.writeBlocking(SocketWrapperBase.java:593) at org.apache.tomcat.util.net.SocketWrapperBase.write(SocketWrapperBase.java:537) at org.apache.coyote.http11.Http11OutputBuffer$SocketOutputBuffer.doWrite(Http11OutputBuffer.java:547) at org.apache.coyote.http11.filters.ChunkedOutputFilter.doWrite(ChunkedOutputFilter.java:110) at org.apache.coyote.http11.Http11OutputBuffer.doWrite(Http11OutputBuffer.java:194) at org.apache.coyote.Response.doWrite(Response.java:615) at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:340) ... 25 common frames omitted Caused by: java.io.IOException: 远程主机强迫关闭了一个现有的连接。 at sun.nio.ch.SocketDispatcher.write0(Native Method) ~[na:1.8.0_102] at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:51) ~[na:1.8.0_102] at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93) ~[na:1.8.0_102] at sun.nio.ch.IOUtil.write(IOUtil.java:65) ~[na:1.8.0_102] at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471) ~[na:1.8.0_102] at org.apache.tomcat.util.net.NioChannel.write(NioChannel.java:135) ~[tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.doWrite(NioEndpoint.java:1384) ~[tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.tomcat.util.net.SocketWrapperBase.doWrite(SocketWrapperBase.java:773) ~[tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.tomcat.util.net.SocketWrapperBase.writeBlocking(SocketWrapperBase.java:593) ~[tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.tomcat.util.net.SocketWrapperBase.write(SocketWrapperBase.java:537) ~[tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.coyote.http11.Http11OutputBuffer$SocketOutputBuffer.doWrite(Http11OutputBuffer.java:547) ~[tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.coyote.http11.filters.ChunkedOutputFilter.doWrite(ChunkedOutputFilter.java:112) ~[tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.coyote.http11.Http11OutputBuffer.doWrite(Http11OutputBuffer.java:194) ~[tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.coyote.Response.doWrite(Response.java:615) ~[tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:340) ~[tomcat-embed-core-9.0.63.jar:9.0.63] ... 24 common frames omitted
06-07
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值