当前位置:网站首页>刷题-洛谷-P1319 压缩技术
刷题-洛谷-P1319 压缩技术
2022-08-04 19:44:00 【宋向上_UP】
P1319 压缩技术-C语言
1、题目

2、求解过程
结果:
代码:
//洛谷 P1319 压缩技术
#include <stdio.h>
#define NUM 200
int main() {
int n;
int m;//表示输入了多少个数
int figure[NUM];
int i = 0;
int j;
int sum = 0;
int counter = 0;//计数器 每N个数打印一个换行
scanf("%d", &n);
/* for (i = 0; i < n; i++) { scanf_s("%d", &figure[i]); }*/
while (sum < (n * n)) {
scanf("%d", &figure[i]);
sum = sum + figure[i];
i++;
}
m = i;
for (i = 1; i <= m; i++) {
j = 1;
if (i % 2 == 1) {
while (j <= figure[i - 1]) {
printf("0");
counter++;
if (counter == (n * n)) {
//去除最后一个换行
break;
}
if (counter % n == 0) {
printf("\n");
}
j++;
}
}
else {
while (j <= figure[i - 1]) {
printf("1");
counter++;
if (counter == (n * n)) {
//去除最后一个换行
break;
}
if (counter % n == 0) {
printf("\n");
}
j++;
}
}
//printf("\n打印了%d次啦\n", i);
}
return 0;
}
边栏推荐
- June To -.-- -..- -
- Polygon zkEVM 基本概念
- Query the published version records of the APP Store
- IIC驱动OLED
- 使用 Chrome 开发者工具的 lighthouse 功能分析 web 应用的性能问题
- SAP UI5 确保控件 id 全局唯一的实现方法
- In July 2022, domestic database memorabilia
- 华为企业组网实例:VRRP+MSTP典型组网配置
- How to promote the implementation of rural revitalization
- 重构指标之如何监控代码圈复杂度
猜你喜欢
随机推荐
重构指标之如何监控代码圈复杂度
SAP UI5 ensures that the control id is globally unique implementation method
拥抱Cmake小朋友 简单又实用,但是不灵活
Switch node version and switch npm source tool
量化交易机器人系统开发
SIGIR 2022 | 邻域建模Graph-Masked Transformer,显著提高CTR预测性能
[Awards for Essays] Autumn recruitment special training to create your exclusive product experience
Chrome 开发者工具 performance 标签页的用法
Highlights of some performance tests
PostgreSQL的 SPI_接口函数
红外图像滤波
Openharmony code framework (2) the person that
【Attention 演变史】RNN的产生、架构、推广、问题(第一弹)
二叉树的前序遍历
To -.-- -..- -
元国度链游系统开发
【ASP.NET Core】 中间件
MogDB学习笔记-环境准备及单实例安装
Query the published version records of the APP Store
Seata source code analysis: various message processing processes of seata server




![[Sql brush topic] Query information data--Day1](/img/a7/67b59bd41803dfc07ecb8f00669c29.png)



