当前位置:网站首页>蓝桥历届真题-蛇形填数
蓝桥历届真题-蛇形填数
2022-08-09 13:04:00 【CoolTiger_程序员】

答案:761
解法有很多,但我觉得对于这道填空题最好的解法是找规律,竞赛不是比谁写的代码更高级更花里胡哨,而是解决问题,不管你用的是什么方法,当然越优越快最好。

思路:找规律,题目求20行20列,当你找出11,22,33,44,55,66时,你会发现它是有规律的。
这样做的好处就是可以验证前几次的数据是否对的上,对的上那答案就是对的。
代码实现:
#include<stdio.h>
int main(){
int i,a=4;
int sum=1;
for(i=0;i<20;i++){
printf("%d\n",sum);
sum+=a;
a+=4;
}
return 0;
}
1 5 13 25 41 61 85 113 145 181 221 265 313 365 421 481 545 613 685 761
--------------------------------
Process exited after 0.142 seconds with return value 0
请按任意键继续. . .
当然如果要求的n行n列的n过于大时,可以分别把结果前面打印i序号即可。
边栏推荐
- FPGA中串口通信的时钟频率和波特率计数
- 基于 R 语言的深度学习——简单回归案例
- NFS 特别注意权限的问题
- Professor Chen Qiang "application in machine learning and R" course chapter 17
- The sword refers to Offer 56 - II. Number of occurrences of a number in an array II (bit operation)
- Yocto 可以下载的第三方库
- Oracle Recovery Tools修复空闲坏块
- Professor Chen Qiang's "Machine Learning and R Application" course Chapter 16 Assignment
- render解析
- read stream special attention
猜你喜欢

FFmpeg multimedia file processing (the basic concept of ffmpeg processing stream data)

WSA工具箱安装应用商店提示无法工作怎么解决?

render解析

gin's middleware and routing grouping

技嘉显卡 RGBFusion 不能调光解决方法

The FPGA - work summary recently

WSA toolkit installed app store tip doesn't work how to solve?

电脑重装系统后桌面图标如何调小尺寸

GIN file upload and return

uni-app - uview Swiper 轮播图组件点击跳转链接(点击后拿到 item 行数据, 取出数据做操作)
随机推荐
七夕力扣刷不停,343. 整数拆分(剑指 Offer 14- I. 剪绳子、剑指 Offer 14- II. 剪绳子 II)
某高校的R语言数据分析期末作业
搭建大型分布式服务(四)Docker搭建开发环境安装Mysql
Professor Chen Qiang the machine learning and R application course chapter 18 assignments
GIN文件上传与返回
Q_04_04 Q#类型模型
【奖励公示】第23期 2022年7月奖励名单公示:社区明星评选 | 新人奖 | 博客同步 | 推荐奖
GIN file upload and return
用plot_hist_numeric()实现画直方图
Jenkins API groovy调用实践: Jenkins Core Api & Job DSL创建项目
Q_04_05 使用Qubits
Record the system calls and C library functions used in this project-2
JS本地存储 sessionStorage和localStorage
01_iTween_第一天--小球抛物线
Time series analysis course lab report
搭建大型分布式服务(二)搭建会员服务
自己做了个nodejs+epxress+mysql的小项目,怎么才能让别人通过互联网访问呢?
群组行动控制--自动队列化实现策略
CPU-MIPS32 instruction architecture (unlocked pipeline microprocessor)
【瑞吉外卖】day05:增、删、改、查分类以及公共字段自动填充
