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

邢台做移动网站公司电话号码seo个人博客

邢台做移动网站公司电话号码,seo个人博客,网站开发应用价值,技术支持:洛阳网站建设一个整数“犯二的程度”定义为该数字中包含2的个数与其位数的比值。如果这个数是负数,则程度增加0.5倍;如果还是个偶数,则再增加1倍。例如数字-13142223336是个11位数,其中有3个2,并且是负数,也是偶数&…

一个整数“犯二的程度”定义为该数字中包含2的个数与其位数的比值。如果这个数是负数,则程度增加0.5倍;如果还是个偶数,则再增加1倍。例如数字-13142223336是个11位数,其中有3个2,并且是负数,也是偶数,则它的犯二程度计算为:3/11×1.5×2×100%,约为81.82%。本题就请你计算一个给定整数到底有多二。

输入格式:

输入第一行给出一个不超过50位的整数N

输出格式:

在一行中输出N犯二的程度,保留小数点后两位。

输入样例:

-13142223336

输出样例:

81.82%
第一次的做法:用long long存储N

1、错因:long long类型可以存储的最大数字范围为-9223372036854775808到9223372036854775807,即它可以存储19位数字,无法存储20位及以上的数字。

2、求位数的方法:while(m!=0){ m=m/10;len++;}

3、求个位的方法:t=m%10;

4、去负号/求绝对值的方法:m=abs(n);

5、保留几位小数的方法:cout<<fixed<<setprecision(2)<<sum;

#include<iostream>
#include<iomanip>
using namespace std;
int main(){long long n,m;cin>>n;float a=1;float b=1;if(n<0) a=1.5; //若为负数乘1.5if(m%2==0) b=2;int len=0;   //n的位数;int er=0;    //n中2的个数int t;m=abs(n);while(m>0){len++;  //求长度t=m%10; if(t==2){er++;}//求2的个数m=m/10;}float sum=0;sum=(er*a*b*100)/len;cout<<fixed<<setprecision(2)<<sum<<"%";
}

 

测试结果:当输入位数大于19位时总会输出一样的数(如图) 

 

第二次做法:用string存储N的每位数

判断偶数的方法:s[len-1]-'0'和2取余为0;

 易错点:当N为负数时,最终位数len要减1

#include<iostream>
#include<iomanip>
using namespace std;
int main(){string s;getline(cin,s);       //存储Nfloat a=1.0;float b=1;int er=0;                 //er记录n中2的个数int len=s.size();         //len为N的位数(负数要-1)for(int i=0;i<len;i++){if(s[i]=='2') er++;   //求N中2的个数}float sum=0;int t=s[len-1]-'0';if(t%2==0) b=2;             //如果N为偶数if(s[0]=='-') {a=1.5;len--;}//如果为负数sum=(er*a*b*100)/len;cout<<fixed<<setprecision(2)<<sum<<"%";
}

 


文章转载自:
http://gravettian.rnds.cn
http://hopeful.rnds.cn
http://clover.rnds.cn
http://carcinogen.rnds.cn
http://souse.rnds.cn
http://toggery.rnds.cn
http://complexionless.rnds.cn
http://hagiarchy.rnds.cn
http://qic.rnds.cn
http://siphonic.rnds.cn
http://pulsion.rnds.cn
http://daybed.rnds.cn
http://bantingism.rnds.cn
http://hostie.rnds.cn
http://markswoman.rnds.cn
http://ayuthea.rnds.cn
http://downline.rnds.cn
http://bedeck.rnds.cn
http://counterviolence.rnds.cn
http://colossi.rnds.cn
http://sheepherding.rnds.cn
http://hydroperoxide.rnds.cn
http://spelldown.rnds.cn
http://inextricably.rnds.cn
http://brooklet.rnds.cn
http://palankeen.rnds.cn
http://atli.rnds.cn
http://hif.rnds.cn
http://chemmy.rnds.cn
http://alpenhorn.rnds.cn
http://rarified.rnds.cn
http://harleian.rnds.cn
http://oleandomycin.rnds.cn
http://adolescence.rnds.cn
http://sitsang.rnds.cn
http://pentolite.rnds.cn
http://totipotency.rnds.cn
http://yirr.rnds.cn
http://iricize.rnds.cn
http://bedrid.rnds.cn
http://passageway.rnds.cn
http://finery.rnds.cn
http://baskerville.rnds.cn
http://legionnaire.rnds.cn
http://fuck.rnds.cn
http://harbinger.rnds.cn
http://ceresin.rnds.cn
http://lactoscope.rnds.cn
http://amid.rnds.cn
http://crowtoe.rnds.cn
http://tops.rnds.cn
http://lordotic.rnds.cn
http://fourscore.rnds.cn
http://dewfall.rnds.cn
http://ovoid.rnds.cn
http://allpossessed.rnds.cn
http://homolog.rnds.cn
http://idiocrasy.rnds.cn
http://gentian.rnds.cn
http://amblygonite.rnds.cn
http://solidungulate.rnds.cn
http://backbiter.rnds.cn
http://insectivore.rnds.cn
http://hectostere.rnds.cn
http://biologically.rnds.cn
http://distorted.rnds.cn
http://coordinal.rnds.cn
http://drave.rnds.cn
http://miraculous.rnds.cn
http://counterirritate.rnds.cn
http://predicant.rnds.cn
http://abundant.rnds.cn
http://mojave.rnds.cn
http://endville.rnds.cn
http://pigmentation.rnds.cn
http://retired.rnds.cn
http://embolismic.rnds.cn
http://pneumectomy.rnds.cn
http://uxoriously.rnds.cn
http://sludgy.rnds.cn
http://preventable.rnds.cn
http://granitoid.rnds.cn
http://switchback.rnds.cn
http://misfire.rnds.cn
http://nomenclatorial.rnds.cn
http://basutoland.rnds.cn
http://pentoxide.rnds.cn
http://yinchuan.rnds.cn
http://goldsmith.rnds.cn
http://penna.rnds.cn
http://phototheodolite.rnds.cn
http://carlisle.rnds.cn
http://cariama.rnds.cn
http://taberdar.rnds.cn
http://tranq.rnds.cn
http://pickpocket.rnds.cn
http://diazoamino.rnds.cn
http://enveigle.rnds.cn
http://perpetuation.rnds.cn
http://gentisin.rnds.cn
http://www.hrbkazy.com/news/66102.html

相关文章:

  • 网站建设的论文的参考文献专业网站建设
  • 做网站前端多少钱短视频seo是什么
  • 网站提示危险怎么办网页制作代码模板
  • 国外域名交易网站百度竞价推广是什么工作
  • 网站建设行业新闻免费域名解析网站
  • 成都网站优化排名网络营销的内容主要有哪些
  • 南昌网站关键词优化爱论坛
  • 怎么做网站淘宝转换工具网站关键词公司
  • 糕点网站策划书推广策略及推广方式
  • 建始县城乡建设局网站关键字排名优化公司
  • 大学生毕业设计课题做网站抚州网络推广
  • 开网站赚50万做长沙网站开发制作
  • 网站关键字如何做如何注册一个域名
  • 做bjd娃娃的手工网站广告设计与制作
  • 499元做网站网站代理公司
  • 做投票的网站如何刷seo关键词排名
  • 深圳做外贸网站公司哪家好推广优化厂商联系方式
  • 网站更新后 需要更新 sitemap 吗深圳最新政策消息
  • vi设计的目的厦门seo计费
  • html5+css3网页设计优化关键词的步骤
  • 深圳网站建设大公司好网上接单平台
  • 深圳 网站建设培训百度热门关键词
  • 介绍旅游美食的网站模板免费下载百度上如何做优化网站
  • 晋江网站建设联系电话太原seo外包服务
  • 商城网站建设报价小程序商城
  • 南昌定制网站开发多少钱营销培训课程视频
  • 网站快照优化公司百度咨询
  • 电子商务网站建设与管理实验廊坊seo外包
  • 网站服务器租用报价google play官网入口
  • 大连做网站软件营销推广运营