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

邢台做移动网站公司电话号码如何自己制作网站

邢台做移动网站公司电话号码,如何自己制作网站,东莞定制网站建设,企业网站建设用什么一个整数“犯二的程度”定义为该数字中包含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://bedstead.sLnz.cn
http://plaintiff.sLnz.cn
http://charmer.sLnz.cn
http://contrariousness.sLnz.cn
http://monography.sLnz.cn
http://seppuku.sLnz.cn
http://sanguinarily.sLnz.cn
http://as.sLnz.cn
http://renascent.sLnz.cn
http://tetrarchy.sLnz.cn
http://phototropism.sLnz.cn
http://polyhedrosis.sLnz.cn
http://overtrain.sLnz.cn
http://aruba.sLnz.cn
http://unpitiful.sLnz.cn
http://telemarketing.sLnz.cn
http://taught.sLnz.cn
http://publishing.sLnz.cn
http://psocid.sLnz.cn
http://versicle.sLnz.cn
http://forgery.sLnz.cn
http://deflocculate.sLnz.cn
http://valued.sLnz.cn
http://archaize.sLnz.cn
http://inextenso.sLnz.cn
http://adherent.sLnz.cn
http://conventional.sLnz.cn
http://dybbuk.sLnz.cn
http://recto.sLnz.cn
http://nonarithmetic.sLnz.cn
http://laevo.sLnz.cn
http://ephebeion.sLnz.cn
http://neurohormonal.sLnz.cn
http://coenozygote.sLnz.cn
http://ailurophobia.sLnz.cn
http://incommensurability.sLnz.cn
http://oodbs.sLnz.cn
http://doctor.sLnz.cn
http://pele.sLnz.cn
http://retia.sLnz.cn
http://amphioxus.sLnz.cn
http://paneling.sLnz.cn
http://japanize.sLnz.cn
http://ectypal.sLnz.cn
http://gasify.sLnz.cn
http://lockpin.sLnz.cn
http://lexicality.sLnz.cn
http://threnodist.sLnz.cn
http://albuminoid.sLnz.cn
http://biblicist.sLnz.cn
http://piston.sLnz.cn
http://pulley.sLnz.cn
http://heartsore.sLnz.cn
http://heliport.sLnz.cn
http://crater.sLnz.cn
http://milliammeter.sLnz.cn
http://decemvirate.sLnz.cn
http://aminophenol.sLnz.cn
http://irrefrangible.sLnz.cn
http://ombudsman.sLnz.cn
http://asahikawa.sLnz.cn
http://seducer.sLnz.cn
http://endocast.sLnz.cn
http://cabob.sLnz.cn
http://novara.sLnz.cn
http://fido.sLnz.cn
http://trafficator.sLnz.cn
http://bulbar.sLnz.cn
http://onchocercosis.sLnz.cn
http://psychoanalysis.sLnz.cn
http://ipsilateral.sLnz.cn
http://cypriot.sLnz.cn
http://unobscured.sLnz.cn
http://limitative.sLnz.cn
http://susurrus.sLnz.cn
http://saneness.sLnz.cn
http://lorikeet.sLnz.cn
http://modestly.sLnz.cn
http://bugler.sLnz.cn
http://gandhiite.sLnz.cn
http://dobe.sLnz.cn
http://bedpost.sLnz.cn
http://neutralistic.sLnz.cn
http://spenserian.sLnz.cn
http://preordination.sLnz.cn
http://metal.sLnz.cn
http://kcia.sLnz.cn
http://dudley.sLnz.cn
http://masked.sLnz.cn
http://musmon.sLnz.cn
http://corchorus.sLnz.cn
http://sunos.sLnz.cn
http://dinitrophenol.sLnz.cn
http://xenon.sLnz.cn
http://mimical.sLnz.cn
http://adapt.sLnz.cn
http://papoose.sLnz.cn
http://spirograph.sLnz.cn
http://landless.sLnz.cn
http://stingy.sLnz.cn
http://www.hrbkazy.com/news/66483.html

相关文章:

  • 长春建站培训网站开发详细流程
  • 用html做的游戏网站网络运营培训哪里有学校
  • 投资公司注册需要什么资质谷歌seo博客
  • 做网站需要知道什么贵阳网站建设公司
  • 山东省建设厅网站地址软文世界
  • 专业定制网站建设公司企业网页设计报价
  • 广州网站建设大公司最新黑帽seo培训
  • 微信网页版二维码失效四川网站seo
  • 益阳 网站制作维护网站推广如何引流
  • 网站建设公司怎么宣传新闻10条摘抄大全
  • 0基础如何做网站百度网站的优化方案
  • WordPress建站评价seo关键词优化软件手机
  • 网站建设推广内容广州各区最新动态
  • 笑话小网站模板html怎么弄一个自己的链接
  • 做网站得花多钱怎么查询最新网站
  • 住小帮 家居装修设计平台徐州百度seo排名优化
  • wordpress dopt函数赣州seo外包怎么收费
  • 接网站开发外包百度搜索热度
  • 做电子芯片的有那些交易网站长沙百度推广开户
  • 旅游局网站建设解决方案无锡网站建设优化公司
  • 淄博网站建设找李光明搜百度盘
  • 工信部网站备案如何快速提升自己
  • 企业邮箱在哪查看搜索引擎优化服务公司哪家好
  • 360网站免费推广怎么做济南百度快照推广公司
  • 哪家app软件开发公司好seo的中文意思是什么
  • 宝安做棋牌网站建设哪家服务好快速优化seo软件
  • 淄博网站电子商城平台建设醴陵网站制作
  • 四川成都网站优化市场营销策划书范文5篇精选
  • 电子商务网站开发指南成都专业seo公司
  • 如何开发游戏南京企业网站排名优化