当前位置:网站首页>蓝桥历届真题-蛇形填数
蓝桥历届真题-蛇形填数
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序号即可。
边栏推荐
- FFmpeg多媒体文件处理(ffmpeg打印音视频Meta信息)
- IDEA Gradle 常遇问题(一)
- Jenkins API groovy calling practice: Jenkins Core Api & Job DSL to create a project
- Q_04_06 把它放在一起:传送
- 5G China unicom AP:B SMS ASCII Transcoding Requirements
- Professor Chen Qiang's "Machine Learning and R Application" course Chapter 14 Assignment
- FFmpeg multimedia file processing (FFMPEG logging system)
- 周末看点回顾|我国IPv6网络全面建成;2022昇腾AI开发者创享日·南京站成功举办…
- 万物皆可柯里化的 Ramda.js
- ARM板卡增加路由功能
猜你喜欢
kustomize entry example and basic syntax instructions
GIN a preliminary study, the environment is installed
面试攻略系列(二)-- 秒杀系统
5G China unicom repeater network management protocol real-time requirements
Unity3d_API_GPS_LocationService
eslint语法规则报错
微服务+微信小程序实现社区服务
5G China unicom general exception handling
剑指offer,剪绳子2
5G China unicom AP:B SMS ASCII 转码要求
随机推荐
eslint语法规则报错
gin's middleware and routing grouping
剑指 Offer 21. 调整数组顺序使奇数位于偶数前面(循环不变量)
【NVIDIA】Tesla V100安装NVIDIA-Driver驱动程序适配CUDA-Toolkit-11.6
剑指 Offer 57 - II. 和为s的连续正数序列(滑动窗口)
5G China unicom repeater network management protocol real-time requirements
七夕力扣刷不停,343. 整数拆分(剑指 Offer 14- I. 剪绳子、剑指 Offer 14- II. 剪绳子 II)
Q_06_01 Q#编程语言
绘制混合密度函数图以及添加分位数线
IDEA Gradle 常遇问题(一)
How to solve the 0x80070005 error when the computer is reinstalled and the system is restored
Rmarkdown教程
Q_06_04 语句和其他构造
Unity3d_API_Gyroscope 陀螺仪的接口
剑指 Offer 43. 1~n 整数中 1 出现的次数(递归、数学)
WSA toolkit installed app store tip doesn't work how to solve?
FFmpeg multimedia file processing (implementation of ffmpeg operation directory and list)
offset、client、scroll、window.pageYOffset比较
Microsoft 10/11 命令行打开系统设置页(WUAP,!WIN32)
搭建大型分布式服务(二)搭建会员服务