当前位置:网站首页>刷题-洛谷-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;
}
边栏推荐
- AWS SES 的监控和告警
- ERC20转账压缩
- 拥抱Cmake小朋友 简单又实用,但是不灵活
- The establishment of simple data cache layer
- Client Side Cache 和 Server Side Cache 的区别
- The book "The Essence of Alipay Experience Design", a record of knowledge related to testing
- IIC驱动OLED
- Finger Vein Recognition-matlab
- JS手写JSON.stringify() (面试)
- visual studio 与 visual studio code
猜你喜欢

【着色器实现Glitch单项故障闪烁效果(与Television效果不同)_Shader效果第十四篇】

TritonVM——基于Recursive STARK的虚拟机

电脑一键重装系统内存完整性无法打开怎么办

高效目标检测:动态候选较大程度提升检测精度(附论文下载)

MogDB学习笔记-环境准备及单实例安装

JS手写JSON.stringify() (面试)

Openharmony code framework (2) the person that

SIGIR 2022 | 邻域建模Graph-Masked Transformer,显著提高CTR预测性能

「 WAIC 2022 · 黑客马拉松」蚂蚁财富两大赛题邀你来战!

Dragoma (DMA) Metaverse System Development
随机推荐
Elastic Search 根据匹配分和热度分排序
哈佛架构 VS 冯·诺依曼架构
[Sql brush topic] Query information data--Day1
【Attention演变史】翻译模型seq2seq (第二弹)
LED的C语言应用程序
拥抱Cmake小朋友 简单又实用,但是不灵活
openharmony代码框架初识(2)
really time ntp service start command
Ant Group's time series database CeresDB is officially open source
运维就业现状怎么样?技能要求高吗?
JS new一个构造器发生了什么?从零手写一个new方法
Embrace the Cmake child is simple and practical, but inflexible
如何让远在的老板看到你!----------来自财富中国网
编译optimize源码实现过程
The Development and Current Situation of Object Detection
v-model的使用
前3名突然变了,揭秘 7 月编程语言最新排行榜
Notepad++更改显示背景
How to promote the implementation of rural revitalization
In July 2022, domestic database memorabilia