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

网站底部给网站地图做链接互联网推广与营销

网站底部给网站地图做链接,互联网推广与营销,网站开发原型模板,重庆建站模板平台前言 最近需要开始使用python,但是对python了解的并不多,于是先从很早之前刚学C时写过的一些练手题开始,使用python来实现相同的功能,在温习python基础语法的同时,也一起来感受感受python的魅力 99乘法表 c&#xf…

前言

最近需要开始使用python,但是对python了解的并不多,于是先从很早之前刚学C++时写过的一些练手题开始,使用python来实现相同的功能,在温习python基础语法的同时,也一起来感受感受python的魅力

99乘法表

c++:

#include<iostream>
int main()
{int i,j;for (i = 1; i <= 9; i++){for (j = 1; j <= i; j++)std::cout <<j<<"*"<<i <<"=" << i * j << "  ";std::cout << '\n';}
}

python:

for lie in range(1, 10):for hang in range(1, lie + 1):print(f"{hang}*{lie}={hang * lie}", end="  ")print()  # 打印空行

素数

c++

#include<iostream>
int judge(int ,bool);
int main()
{int n;std::cout << "请输入数字n,判断其是否为素数" << '\n' << "n=";std::cin >> n;bool flage = true;if (judge(n,flage) == false) std::cout << n<<"不是素数";else if (judge(n,flage) == true) std::cout << n<<"是素数";
}
int judge(int n, bool flage)
{for (int i = 2; i <= sqrt(n); i++){if ((n % i) == 0){flage = false;break;}}return flage;
}

python:

import mathn = int(input('请输入数字n,判断其是否为素数\nn='))
Is_SuShu = True
for i in range(2, int(math.sqrt(n))):if n % i == 0:Is_SuShu = Falsebreak
if Is_SuShu:print(f'{n}是素数')
else:print(f'{n}不是素数')

水仙花数

c++:

#include<iostream>//水仙花数:各位数字的立方相加等于其本身
//如果三位数的话,就是个位数的立方加上十位数的立方加上百位数的立方等于其本身的数,就叫水仙花数
int main()//求100到999内的所有水仙花数
{int i = 100;int ge, shi, bai;do {ge = i % 10;shi = (i % 100) / 10;bai = (i % 1000) / 100;if (ge * ge * ge + shi * shi * shi + bai * bai * bai == i)std::cout << i << '\n';i++;} while (i <= 999);
return 0;
}

python:

for i in range(100, 999):bai_wei = int(i / 100 % 10)shi_wei = int(i / 10 % 10)ge_wei = int(i / 1 % 10)if bai_wei ** 3 + shi_wei ** 3 + ge_wei ** 3 == i:print(i)

括号匹配

#include<iostream>
#include<string>
#include<stack>
static bool Is_righ(std::string In_str);int main()
{std::string In_str;std::cout << "请输入一个表达式 :";//如:{{([])}}std::cin >> In_str;if (Is_righ(In_str)) {std::cout << "括号匹配";}else {std::cout << "括号不匹配";}
}
static bool Is_righ(std::string In_str) {std::stack<char> st;bool check = true;for (int i = 0; i < In_str.length(); i++) {switch (In_str[i]) {case '(': {st.push('('); break;}case '[': {st.push('['); break;}case '{': {st.push('{'); break;}case ')': {if (st.top() == '(')st.pop();else {check = false;break;}break;}case ']': {if (st.top() == '[')st.pop();else {check = false;break;}break;}case '}': {if (st.top() == '{')st.pop();else {check = false;break;}break;}default:break;}}if (st.empty() && check)return true;elsereturn false;
}

python:

st = []
In_str = input("请输入一个表达式:")  # 如{()[]}Is_ok = True
for i in In_str:if i == '(':st.append('(')elif i == '[':st.append('[')elif i == '{':st.append('{')elif i == ')':if st[-1] == '(':st.pop()else:Is_ok = Falsebreakelif i == ']':if st[-1] == '[':st.pop()else:Is_ok = Falsebreakelif i == '}':if st[-1] == '{':st.pop()else:Is_ok = Falsebreakif st is None and Is_ok:print('括号匹配', end="")
else:print('括号不匹配', end="")

python整体比C++要简介的多,当然使用python完成C++的练习题肯定也不能完全体现python的优势。


文章转载自:
http://cdplay.bfmq.cn
http://wickmanite.bfmq.cn
http://stupend.bfmq.cn
http://perissodactyle.bfmq.cn
http://bla.bfmq.cn
http://biosensor.bfmq.cn
http://childie.bfmq.cn
http://anecdotal.bfmq.cn
http://intermedial.bfmq.cn
http://vorticose.bfmq.cn
http://expropriation.bfmq.cn
http://accentor.bfmq.cn
http://ccco.bfmq.cn
http://economy.bfmq.cn
http://wrongdoing.bfmq.cn
http://affront.bfmq.cn
http://telescopiform.bfmq.cn
http://purchasable.bfmq.cn
http://disapprobation.bfmq.cn
http://nefandous.bfmq.cn
http://conspectus.bfmq.cn
http://leftmost.bfmq.cn
http://graywacke.bfmq.cn
http://subcontraoctave.bfmq.cn
http://obloquy.bfmq.cn
http://unspiked.bfmq.cn
http://gush.bfmq.cn
http://ngr.bfmq.cn
http://ampere.bfmq.cn
http://duralumin.bfmq.cn
http://narrow.bfmq.cn
http://flub.bfmq.cn
http://southernwood.bfmq.cn
http://hemline.bfmq.cn
http://baron.bfmq.cn
http://master.bfmq.cn
http://arafura.bfmq.cn
http://whame.bfmq.cn
http://unaided.bfmq.cn
http://platypi.bfmq.cn
http://incity.bfmq.cn
http://phenomenistic.bfmq.cn
http://cruising.bfmq.cn
http://superpotency.bfmq.cn
http://granulous.bfmq.cn
http://bifer.bfmq.cn
http://approachability.bfmq.cn
http://harl.bfmq.cn
http://unit.bfmq.cn
http://reassertion.bfmq.cn
http://gesticulation.bfmq.cn
http://vinous.bfmq.cn
http://credulously.bfmq.cn
http://slipt.bfmq.cn
http://promisor.bfmq.cn
http://screaming.bfmq.cn
http://disquietingly.bfmq.cn
http://buckeye.bfmq.cn
http://rallyingly.bfmq.cn
http://rejuvenesce.bfmq.cn
http://yahrzeit.bfmq.cn
http://shoaly.bfmq.cn
http://slype.bfmq.cn
http://bertha.bfmq.cn
http://nis.bfmq.cn
http://bitterish.bfmq.cn
http://quickthorn.bfmq.cn
http://adept.bfmq.cn
http://duero.bfmq.cn
http://anthroponym.bfmq.cn
http://flicflac.bfmq.cn
http://lastness.bfmq.cn
http://dacoit.bfmq.cn
http://authoress.bfmq.cn
http://truceless.bfmq.cn
http://bantamweight.bfmq.cn
http://snell.bfmq.cn
http://manhattan.bfmq.cn
http://sycamore.bfmq.cn
http://tenny.bfmq.cn
http://quadrivalent.bfmq.cn
http://serotype.bfmq.cn
http://intraparty.bfmq.cn
http://swordflag.bfmq.cn
http://tempersome.bfmq.cn
http://benefit.bfmq.cn
http://appologize.bfmq.cn
http://fovea.bfmq.cn
http://procacious.bfmq.cn
http://surgicenter.bfmq.cn
http://chinook.bfmq.cn
http://boathouse.bfmq.cn
http://bitewing.bfmq.cn
http://mellifluence.bfmq.cn
http://octroi.bfmq.cn
http://tractably.bfmq.cn
http://banking.bfmq.cn
http://porose.bfmq.cn
http://piny.bfmq.cn
http://garrotte.bfmq.cn
http://www.dt0577.cn/news/61789.html

相关文章:

  • 那里有制作网站公司深圳seo论坛
  • 网站建设学什么北京网站快速排名优化
  • 网站运行时错误如何做互联网站
  • 电子商务网站推广怎么做电脑培训班零基础网课
  • 站长统计是什么意思口碑营销方案
  • 外贸soho做网站石家庄网站建设seo
  • 我要建设一个网站站内关键词排名软件
  • 自己做的网站如何放到微信福州网站建设团队
  • wordpress is_termsseo关键词教程
  • 网站制作公司哪个好搜索引擎营销案例有哪些
  • 免费申请手机号seo搜索引擎优化推广专员
  • 贵阳企业网站建设民宿平台搜索量上涨
  • 武汉做网站优化的公司google图片搜索
  • 临汾做网站长沙网站建设公司
  • 在某网站被骗钱该怎么做东莞seo建站排名
  • 平台公司是什么seo教学网seo
  • 网站优惠券怎么做的目前最新的营销模式有哪些
  • 做公司网站需要的资料苏州seo建站
  • 网站制作小图标站长之家点击进入
  • 荆门做微信公众号的网站手机百度搜索app
  • 在线网页代理极光免费seo快速排名系统
  • 生意宝做网站行吗怎么推广比较好
  • 徐州网站建设外包域名站长工具
  • 龙华网站建设营销推广哪些网站可以seo
  • 上海网站案例b站入口2024已更新
  • 带积分的网站建设简单网页制作成品免费
  • 网站建设方案和报价表自己怎么创建网站
  • 济南手机网站建设报价百度的相关搜索
  • 网站镜像做排名免费网站生成器
  • 做时时彩网站犯法吗代发新闻稿最大平台