当前位置: 首页 > wzjs >正文

网站备案最快几天如何给公司做网络推广

网站备案最快几天,如何给公司做网络推广,视频网站点击链接怎么做,遵义网站建设找工作问题描述 小C发现了一种奇特的图案,叫做螺旋阵列。它由一串0和1组成,看起来像一个由外向内旋转的图形。小C想知道,能否根据给定的宽度来生成这样一个螺旋图案。 例如,宽度为5时的螺旋阵列如下: 11111 00001 11101 1…

问题描述

小C发现了一种奇特的图案,叫做螺旋阵列。它由一串0和1组成,看起来像一个由外向内旋转的图形。小C想知道,能否根据给定的宽度来生成这样一个螺旋图案。

例如,宽度为5时的螺旋阵列如下:

11111
00001
11101
10001
11111

宽度为10时的螺旋阵列如下:

1111111111
0000000001
1111111101
1000000101
1011110101
1010010101
1010000101
1011111101
1000000001
1111111111

小C想知道,对于任意给定的宽度 n,是否能生成对应的螺旋图案,并且以一个二维数组的形式输出。


测试样例

样例1:

输入:width = 5
输出:[[1, 1, 1, 1, 1], [0, 0, 0, 0, 1], [1, 1, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]

样例2:

输入:width = 8
输出:[[1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1]]

样例3:

输入:width = 2
输出:[[1, 1], [0, 1]]

 

#include <cassert>
#include <iostream>
#include <vector>
#include <algorithm>using namespace std;std::vector<std::vector<int>> solution(int width) {// Ensure the input width is greater than 1assert(width > 1);// Handle special casesif (width == 2) {return {{1, 1}, {0, 1}};}if (width == 3) {return {{1, 1, 1}, {0, 0, 1}, {1, 1, 1}};}// Recursively generate a smaller spiralvector<vector<int>> base = solution(width - 2);// Initialize the first two rowsvector<vector<int>> res;res.push_back(vector<int>(width, 1));res.push_back(vector<int>(width, 0));res[1][width - 1] = 1;// Add the smaller spiral in reverse order with bordersfor (int i = width - 3; i >= 0; i--) {vector<int> row = base[i];reverse(row.begin(), row.end());row.push_back(0);row.push_back(1);res.push_back(row);}// Fix the second last element of the last rowres[res.size() - 1][res[0].size() - 2] = 1;return res;
}int main() {// You can add more test cases herestd::vector<std::vector<int>> expected1 = {{1, 1, 1, 1, 1},{0, 0, 0, 0, 1},{1, 1, 1, 0, 1},{1, 0, 0, 0, 1},{1, 1, 1, 1, 1}};std::vector<std::vector<int>> expected2 = {{1, 1, 1, 1, 1, 1, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 1},{1, 1, 1, 1, 1, 1, 0, 1}, {1, 0, 0, 0, 0, 1, 0, 1},{1, 0, 1, 0, 0, 1, 0, 1}, {1, 0, 1, 1, 1, 1, 0, 1},{1, 0, 0, 0, 0, 0, 0, 1}, {1, 1, 1, 1, 1, 1, 1, 1}};std::vector<std::vector<int>> expected3 = {{1, 1}, {0, 1}};std::cout << (solution(5) == expected1) << std::endl;std::cout << (solution(8) == expected2) << std::endl;std::cout << (solution(2) == expected3) << std::endl;return 0;
}

http://www.dtcms.com/wzjs/117358.html

相关文章:

  • 上海建设工程咨询网站广州线下教学
  • 网站开发联系方式年度关键词
  • 怎么给自己公司做网站网络seo培训
  • 谁做视频网站优化教程
  • 穿着高跟鞋做的网站seo网站优化论文
  • 国家住房和城乡建设网站seo关键词优化经验技巧
  • 做网站手机端如何更新广州公关公司
  • 北京城乡建设网站itmc平台seo优化关键词个数
  • 广州荔湾做网站公司index百度指数
  • 常用的网站类型有哪些类型有哪些类型怎么在百度上发布信息广告
  • 如何更改wordpress登录密码错误seo是什么意思
  • 珠海网站建设 金碟电脑零基础培训班
  • 彩票网站代理app拉新平台
  • 临沂网络网站建设推广软件赚钱违法吗
  • wordpress友情链接设置seo搜索引擎优化薪资水平
  • 常州专业房产网站建设百度电商平台app
  • 怎么制作博客网站刷评论网站推广
  • 网站建设 中企动力南昌正版google下载
  • 免费视频网站制作站长工具备案查询
  • 如何上传ftp网站程序太原百度快照优化排名
  • 让自己的电脑做网站的服务器目前最好的引流推广方法
  • 京东云免费建wordpressseo的工作内容
  • 做个政府网站要多少钱seo运营是什么意思
  • 网站建设中素材网站seo诊断优化方案
  • 南通seo网站诊断网站建设软件
  • 做商城网站产品怎么分布天津seo顾问
  • 服务器能放多少个网站广告公司招聘
  • 建设商城网站的书籍钱南召seo快速排名价格
  • 漂亮的手机网站模板下载百度怎么投广告
  • 新乡手机网站建设哪家专业网站推广途径