当前位置:网站首页>蓝桥历届真题-蛇形填数
蓝桥历届真题-蛇形填数
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序号即可。
边栏推荐
- 电脑重装系统还原0x80070005错误如何解决
- Time series analysis course lab report
- Process/Thread related in Sandbox - 1
- 5G China unicom repeater network management protocol real-time requirements
- The sword refers to the offer, cuts the rope 2
- 5G China unicom AP:B SMS ASCII 转码要求
- 万物皆可柯里化的 Ramda.js
- GIN file upload and return
- 01_iTween_第一天--小球抛物线
- 19、学习MySQL 索引
猜你喜欢
How to solve the 0x80070005 error when the computer is reinstalled and the system is restored
技嘉显卡 RGBFusion 不能调光解决方法
面试攻略系列(二)-- 秒杀系统
The sword refers to the offer, cuts the rope 2
问题系列-如何修改或更新localhost里的值
为什么文字不贴合边
现在40系显卡都快出来了,为何1060型号的显卡还有这么多人用?
蓝桥杯线上模拟赛——Flex 经典骰子布局
FFmpeg多媒体文件处理(ffmpeg操作目录及list的实现)
render解析
随机推荐
Unity3d_API_GPS_LocationService
为什么文字不贴合边
5G 联通网管设计思路
陈强教授《机器学习及R应用》课程 第十三章作业
ftplib+ tqdm upload and download progress bar
Rmarkdown教程
JS本地存储 sessionStorage和localStorage
GIN Bind模式获取参数和表单验证
Dry+Bean+Dataset R语言数据分析,报告英文
快来扔鸡蛋。
gin's middleware and routing grouping
Draw a histogram with plot_hist_numeric()
jenkins api create custom pipeline
FFMPEG多媒体文件处理(ffmpeg文件的删除与重命名)
5G China unicom AP:B SMS ASCII Transcoding Requirements
jenkins api创建自定义pipeline
周末看点回顾|我国IPv6网络全面建成;2022昇腾AI开发者创享日·南京站成功举办…
Process/Thread Related in Sandbox - 2
ftplib+ tqdm 上传下载进度条
剑指offer,剪绳子2