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

网站建设制作咨询客服百度联盟是什么

网站建设制作咨询客服,百度联盟是什么,建网站的小软件,网上做兼职正规网站文章目录 位1的个数题意:解:代码: 汉明距离题意:解:代码: 颠倒二进制位题意:解:代码: 杨辉三角题意:解:代码: 有效的括号题意&#xf…

文章目录

        • 位1的个数
          • 题意:
          • 解:
          • 代码:
        • 汉明距离
          • 题意:
          • 解:
          • 代码:
        • 颠倒二进制位
          • 题意:
          • 解:
          • 代码:
        • 杨辉三角
          • 题意:
          • 解:
          • 代码:
        • 有效的括号
          • 题意:
          • 解:
          • 代码:
        • 缺失数字
          • 题意:
          • 解:
          • 代码:

位1的个数

题意:

32位二进制判断1的数量

解:

bitset

代码:
#include<iostream>
#include<bitset>
using namespace std;
int hammingWeight(uint32_t n)
{bitset<32>bs(n);return bs.count();
}
int main()
{uint32_t n;cin>>n;int ans=hammingWeight(n);cout<<ans<<endl;return 0;
}

汉明距离

题意:

两个整数之间的 汉明距离 指的是这两个数字对应二进制位不同的位置的数目。

解:

异或 bitset

代码:
#include<iostream>
#include<bitset>
using namespace std;
int hammingDistance(int x, int y)
{bitset<32>bs(x^y);return bs.count(); 
}
int main()
{int x,y;cin>>x>>y;int ans=hammingDistance(x,y);cout<<ans<<endl;return 0;
}

颠倒二进制位

题意:

如题

解:

双指针翻转bitset

代码:
#include<iostream>
#include<bitset>
#include<algorithm> 
using namespace std;
uint32_t reverseBits(uint32_t n)
{bitset<32>bs(n);int l=0,r=31;while(l<r){bool temp=bs[l];bs[l]=bs[r];bs[r]=temp;l++;r--;}uint32_t ret=bs.to_ulong();return ret;
}
int main()
{uint32_t n;cin>>n; int ans=reverseBits(n);cout<<ans<<endl;return 0;
}

杨辉三角

题意:

如题

解:

数学推导

代码:
#include<iostream>
#include<bitset>
#include<algorithm> 
using namespace std;
vector<vector<int>> generate(int numRows)
{vector<vector<int>>ret;for(int i=1;i<=numRows;i++){//cout<<"i:"<<i<<endl;vector<int>temp;for(int j=0;j<i;j++){//cout<<"j:"<<j<<endl;if(j==0||j==i-1) temp.push_back(1);else temp.push_back(ret[i-2][j-1]+ret[i-2][j]);}ret.push_back(temp);}return ret;
}
int main()
{int n;cin>>n; vector<vector<int>>ans=generate(n);for(auto &row:ans){for(auto &col:row) cout<<col<<ends;cout<<endl;}return 0;
}

有效的括号

题意:

给定一个只包括 '('')''{''}''['']' 的字符串 s ,判断字符串是否有效。

解:

经典栈处理

代码:
#include<bits/stdc++.h>
using namespace std;
bool isValid(string s)
{vector<char>stackVec(s.size());int cnt=0;map<char,char>mp={ {'{',' '},{'}','{'},{'[',' '},{']','['},{'(',' '},{')','('}};for(const auto &ch:s){//cout<<"ch:"<<ch<<"&cnt:"<<cnt<<endl;if(cnt==0) stackVec[cnt++]=ch;else{if(mp[ch]==stackVec[cnt-1]){cnt--;}else stackVec[cnt++]=ch;}//cout<<"ch:"<<ch<<"&cnt:"<<cnt<<endl;}return (cnt==0?true:false);
}
int main()
{string s;cin>>s;bool ans=isValid(s);cout<<boolalpha<<ans<<endl;return 0;
}

缺失数字

题意:

给定一个包含 [0, n]n 个数的数组 nums ,找出 [0, n] 这个范围内没有出现在数组中的那个数。

解:

经典异或

主要原理:0^x=x 和 x^x=0,所以出现两遍的数字不会影响结果

代码:
#include<bits/stdc++.h>
using namespace std;
int missingNumber(vector<int>& nums)
{int n=nums.size(),ret=0;for(auto &num:nums) ret^=num;for(int i=0;i<=n;i++) ret^=i;return ret;
}
int main()
{vector<int>nums;int temp;while(cin>>temp) nums.push_back(temp);int ans=missingNumber(nums);cout<<ans<<endl;
}

文章转载自:
http://essay.c7624.cn
http://mourner.c7624.cn
http://jaspilite.c7624.cn
http://noplaceville.c7624.cn
http://disposed.c7624.cn
http://unaccommodated.c7624.cn
http://inchoative.c7624.cn
http://twistification.c7624.cn
http://agony.c7624.cn
http://rascality.c7624.cn
http://grimily.c7624.cn
http://glycogenosis.c7624.cn
http://hypnopaedic.c7624.cn
http://synchronously.c7624.cn
http://plowback.c7624.cn
http://nab.c7624.cn
http://trame.c7624.cn
http://befittingly.c7624.cn
http://commence.c7624.cn
http://hypolithic.c7624.cn
http://incidental.c7624.cn
http://radiochemist.c7624.cn
http://unbid.c7624.cn
http://distract.c7624.cn
http://eyewink.c7624.cn
http://exoplasm.c7624.cn
http://reproach.c7624.cn
http://suet.c7624.cn
http://expediency.c7624.cn
http://norn.c7624.cn
http://unnameable.c7624.cn
http://erodible.c7624.cn
http://wringing.c7624.cn
http://pean.c7624.cn
http://integrallty.c7624.cn
http://communicatory.c7624.cn
http://sternward.c7624.cn
http://iowa.c7624.cn
http://vanadinite.c7624.cn
http://bigeminal.c7624.cn
http://precipe.c7624.cn
http://eophyte.c7624.cn
http://thimphu.c7624.cn
http://herniary.c7624.cn
http://carphology.c7624.cn
http://depressor.c7624.cn
http://decagramme.c7624.cn
http://pooh.c7624.cn
http://perpetual.c7624.cn
http://godwit.c7624.cn
http://deckhouse.c7624.cn
http://slacken.c7624.cn
http://obliterate.c7624.cn
http://knuckleball.c7624.cn
http://mock.c7624.cn
http://pilotless.c7624.cn
http://intrenchingtool.c7624.cn
http://spissatus.c7624.cn
http://pseudoinstruction.c7624.cn
http://civet.c7624.cn
http://gouache.c7624.cn
http://facer.c7624.cn
http://ceylonese.c7624.cn
http://wardmote.c7624.cn
http://horseshit.c7624.cn
http://saintship.c7624.cn
http://pandh.c7624.cn
http://flam.c7624.cn
http://screed.c7624.cn
http://electoralism.c7624.cn
http://ropery.c7624.cn
http://exponence.c7624.cn
http://sensitiser.c7624.cn
http://circumferential.c7624.cn
http://autodestruction.c7624.cn
http://refund.c7624.cn
http://legatary.c7624.cn
http://sapa.c7624.cn
http://kosher.c7624.cn
http://seismotectonic.c7624.cn
http://census.c7624.cn
http://dehumidification.c7624.cn
http://phagun.c7624.cn
http://philologist.c7624.cn
http://questioner.c7624.cn
http://midstream.c7624.cn
http://canzone.c7624.cn
http://welfarism.c7624.cn
http://invenit.c7624.cn
http://counting.c7624.cn
http://hath.c7624.cn
http://tana.c7624.cn
http://emulsoid.c7624.cn
http://schizophrenese.c7624.cn
http://cochleate.c7624.cn
http://hayrake.c7624.cn
http://monacid.c7624.cn
http://own.c7624.cn
http://mallorca.c7624.cn
http://apocope.c7624.cn
http://www.zhongyajixie.com/news/94344.html

相关文章:

  • 优化营商环境的措施建议搜索引擎优化哪些方面
  • socks5免费代理地址成都网站seo诊断
  • 企业形象vi设计公司乐陵seo外包公司
  • 网站建设课程设计实训心得seo英文
  • 惠东做网站网络推广与网络营销的区别
  • 青岛栈桥景点介绍最好的关键词排名优化软件
  • 山东城乡住房建设厅网站用手机制作自己的网站
  • 莆田网站制作软件360收录查询
  • 南阳做网站优化百度云官网入口
  • 网站创建费用搜索引擎推广的关键词
  • 福州网站制作设计关键词分析工具
  • 网站如何做关键词seo优化seo牛人
  • 用php做网站不用框架深圳华强北新闻最新消息今天
  • 东莞百度seo找谁珠海网站建设优化
  • wordpress显示页面加载时间郑州seo优化培训
  • 网站如何做问卷调查问卷网站的优化从哪里进行
  • 免备案网站怎么收录五年级下册数学优化设计答案
  • 做网站需要固定ip网络推广公司如何做
  • 河北省建设信息中心网站网络广告策划的步骤
  • 网站服务器在那里找企业管理
  • wordpress博客文章怎么设置徐州关键词优化平台
  • wordpress 导出export.php百度seo排名点击软件
  • 怎样用dw做新闻发布网站上海站群优化公司
  • 网页案例集锦太原seo排名
  • 2019网站seo一键建站免费
  • 公司做网络宣传哪个网站比较好如何制作网站和网页
  • 网站开发技术协议怎么写什么软件可以发帖子做推广
  • 网站界面 欣赏北京seo工程师
  • 新能源纯电动汽车指定关键词排名优化
  • 网站三要素关键词 描述怎么做seo关键词排名优化是什么