当前位置:网站首页>刷题-洛谷-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;
}
边栏推荐
- 简易数据缓存层的建立
- Ant Group's time series database CeresDB is officially open source
- 使用 Chrome 开发者工具的 lighthouse 功能分析 web 应用的性能问题
- Pedestrian fall detection experiment based on YOLOV5
- How to promote the implementation of rural revitalization
- 切换node版本和切换npm源工具
- 【ASP.NET Core】 中间件
- 六月 致 -.-- -..- -
- 工业相机CCD与CMOS
- 正畸MIA微种植体支抗技术中国10周年交流会在沈举办
猜你喜欢
随机推荐
性能测试流程
JS new一个构造器发生了什么?从零手写一个new方法
Regular expression is incomplete
Force KouTi (5), the longest text string back
基于YOLOV5行人跌倒检测实验
Go学习笔记(篇一)配置Go开发环境
awk 统计平均 最大 最小值
5 g NR notes
awk statistical average max min
小软件大作用 | 如何省时省力进行Gerber图层快速对比?
程序员如何在职场上少走弯路?
正畸MIA微种植体支抗技术中国10周年交流会在沈举办
Chrome 开发者工具 performance 标签页的用法
对比几类主流的跨端技术方案
QT 小知识随记
MySQL远程备份策略举例
正则表达式未完
JSD-2204-酷莎商城(管理员模块)-密码加密-Day10
MYSQL获取数据库的表名和表注释
Orthodontic MIA micro-implant anchorage technology China 10th anniversary exchange meeting was held in Shenyang









