ImageVerifierCode 换一换
你正在下载:

C++.ppt

[预览]
格式:PPT , 页数:54 ,大小:584KB ,
资源ID:2046919      下载积分:14 金币
快捷注册下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

开通VIP
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.zixin.com.cn/docdown/2046919.html】到电脑端继续下载(重复下载【60天内】不扣币)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

开通VIP折扣优惠下载文档

            查看会员权益                  [ 下载后找不到文档?]

填表反馈(24小时):  下载求助     关注领币    退款申请

开具发票请登录PC端进行申请

   平台协调中心        【在线客服】        免费申请共赢上传

权利声明

1、咨信平台为文档C2C交易模式,即用户上传的文档直接被用户下载,收益归上传人(含作者)所有;本站仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。所展示的作品文档包括内容和图片全部来源于网络用户和作者上传投稿,我们不确定上传用户享有完全著作权,根据《信息网络传播权保护条例》,如果侵犯了您的版权、权益或隐私,请联系我们,核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
2、文档的总页数、文档格式和文档大小以系统显示为准(内容中显示的页数不一定正确),网站客服只以系统显示的页数、文件格式、文档大小作为仲裁依据,个别因单元格分列造成显示页码不一将协商解决,平台无法对文档的真实性、完整性、权威性、准确性、专业性及其观点立场做任何保证或承诺,下载前须认真查看,确认无误后再购买,务必慎重购买;若有违法违纪将进行移交司法处理,若涉侵权平台将进行基本处罚并下架。
3、本站所有内容均由用户上传,付费前请自行鉴别,如您付费,意味着您已接受本站规则且自行承担风险,本站不进行额外附加服务,虚拟产品一经售出概不退款(未进行购买下载可退充值款),文档一经付费(服务费)、不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
4、如你看到网页展示的文档有www.zixin.com.cn水印,是因预览和防盗链等技术需要对页面进行转换压缩成图而已,我们并不对上传的文档进行任何编辑或修改,文档下载后都不会有水印标识(原文档上传前个别存留的除外),下载后原文更清晰;试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓;PPT和DOC文档可被视为“模板”,允许上传人保留章节、目录结构的情况下删减部份的内容;PDF文档不管是原文档转换或图片扫描而得,本站不作要求视为允许,下载前可先查看【教您几个在下载文档中可以更好的避免被坑】。
5、本文档所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用;网站提供的党政主题相关内容(国旗、国徽、党徽--等)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
6、文档遇到问题,请及时联系平台进行协调解决,联系【微信客服】、【QQ客服】,若有其他问题请点击或扫码反馈【服务填表】;文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“【版权申诉】”,意见反馈和侵权处理邮箱:1219186828@qq.com;也可以拔打客服电话:0574-28810668;投诉电话:18658249818。

注意事项

本文(C++.ppt)为本站上传会员【a199****6536】主动上传,咨信网仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知咨信网(发送邮件至1219186828@qq.com、拔打电话4009-655-100或【 微信客服】、【 QQ客服】),核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载【60天内】不扣币。 服务填表

C++.ppt

1、2、C+programming A simple C+program Types,variables,expressions1精选课件How to write a programoFind the whole steps in the real modeloUse some graph or nature language to describeoRealize with computer language2精选课件workflow3精选课件Pseudo CodeoA first idea:int main()variableswhile(condition)analyze the expre

2、ssionevaluate the expressionprint the result4 44精选课件main Functionint main(void)return 0;cout“Hello,Tom!”;int x=5;int y=8;int z=x+y;coutx“+”y“=“zendl;55精选课件/2.1.cpp#include using namespace std;/*A simple program for demonstrating the basics of a C+project.*It does a good job of demonstrating C+fundam

3、entals,but a*terrible job with the poetry.*/int main()cout Dont you just feel like a louse;cout endl;cout To learn that your new theorem was proved by Gauss?;cout endl;return 0;66精选课件cout expressionscout“hello,world!”;cout 5;cout x;cout x+5;cout x“+5=”x+5;”n”,“t”,“,endl,setw(n)setw(n):#include cout7

4、7精选课件C+Tokens oA token is the smallest element of a C+program that is meaningful to the compiler.oKinds of tokens:nidentifiers,keywords,literals,operators,punctuators,and other separators.oTokens are usually separated by white space.White space can be one or more blanks,horizontal or vertical tabs,n

5、ew lines,form feeds or comments.88精选课件C+Keywords auto const double float int short struct unsigned unsignedbreak break continue elsefor long switch void case sizeoftypedef char do if returnstatic union while,ETC.99精选课件Commenting/*name of program*information of author*function of program*/a sampleint

6、 main()/*this is in the comment this is also in the comment*/.1010精选课件Constants o1,2,3o1.2,4.50o“name”,“your_phonenumber”oture,falseo0 x12o1,A,$,xhh,dddo#define PI 3.141592o#define PRICE 100oconst int pi=3.141592;1111精选课件/2.2.cpp#include using namespace std;int main()int x;int y;x=3;y=4;cout x+y end

7、l;return 0;1212精选课件Variables TypesoBuilt-in typesnBoolean typeobool 1bytenCharacter typesochar 1bytenInteger typesoint 2-4bytes(2)-3276832767oshort(2)&long(4)-21474836482147483647nFloating-point typesodouble 8bytesofloat 4bytes131 byte(8 bits)2 bytes(16 bits)4 bytes(32 bits)8 bytes(64 bits)16 bytes(

8、128 bits)shortcharboolintfloatlongdoublelong double13精选课件Variables LiteralsoBoolean literals:bool t;ntrue,falseoCharacter literals:char c;na,x,4,n,$oInteger literals:int x;n0,1,123,-6,0 x34,0 xa3oFloating point literals:double d;float f;n1.2,13.345,.3,-0.54,1.2e3,.3F,.3FoString literals:string s;nas

9、df,Howdy,all yall!”1414精选课件Variables NamesoChoose meaningful namesnconfuseomtbf,TLA,myw,nbvnShort names can be meaningfulox is a local variableoi is a loop indexnDont use long namesoOk:npartial_sum,element_count,staple_partitionoToo long:nthe_number_of_elementsremaining_free_slots_in_the_symbol_tabl

10、e1515精选课件Not Variables NamesoA name in a C+programnStarts with a letter,contains letters,digits,and underscores(only)ox,number_of_elements,Fourier_transform,z2nNot names:o12x,time$to$market,main lineoNot start names with underscores:_foonNot use keywordsointoifowhile1616精选课件Declaration and initializ

11、ationint a=7;int b=9;char c=a;double x=1.2;string s1=Hello,world;string s2=1.2;179a1.2 13 Hello,world4|1.2b:c:x:s1:s2:7a:|17精选课件Constant variablesconst int i=5;i=6;/error1818精选课件Think about:oint a,b,c=2;oint x,y,z,10;oint m=2;int n=3;olong int sum=0,add;olong hello;ochar a=m;ochar b,c,d;ochar m=65,n

12、a+1;ofloat a,b,ccc=3.1415;ofloat sum=0.0;odouble f1,f2=1.414e121919精选课件Assignment and incrementint a=7;a=9;a=a+a;a+=2;+a;2079182021a:20精选课件Think aboutoint a=10,b;b=a;ofloat x;int k=300;x=k;ofloat x=3.14;int n;n=x+6;ofloat x=3.14;int n;n=3;ocout x+n;o3.0/9 or (float)3/921精选课件/2.3.cpp A program to il

13、lustrate integer overflow#include using namespace std;/*A program to illustrate what happens when large integers*are multiplied together.*/int main()int million=1000000;int trillion=million*million;cout According to this computer,million squared is trillion .endl;2222精选课件A type-safety violation(“imp

14、licit narrowing”)int main()int a=20000;char c=a;int b=c;if(a!=b)cout oops!:a !=b n;elsecout Wow!We have large charactersn;2320000a?c23精选课件C+character set o0 1 2 3 4 5 6 7 8 9 oA B C D E F G H I J K L M N O P Q R S T U V W X Y Z oa b c d e f g h i j k l m n o p q r s t u v w x y z o_$#()%:;.?*+/&|!=,

15、2424精选课件ASCII code2525精选课件Chars to intsoConvert between a char and its ASCII intnint num=a;nchar let=97;oCycle through the ASCII table with math!nchar bee=a+1;2626精选课件Operatorso+,+o-,-o*o/o%o2727精选课件Arithmetic Assignment OperatorsSymbolExampleEquivalent+=x+=1;x=x+1;*=doub*=2;doub=doub*2;-=n-=5;n=n-5

16、/=third/=3;third=third/3;%=odd%=2;odd=odd%2;28Think about:int a=12;a+=a-=a*a;cout a;28精选课件2929ExpressionsoBoolean type:bool (true and false)nEquality operators:=(equal),!=(not equal)nLogical operators:&(and),|(or),!(not)nRelational operators:(greater than),=oCharacter type:char (a,7,and)oInteger ty

17、pes:short,int,longn arithmetic operators:+,-,*,/,%oFloating-point types:float,double (12.45 and 1.234e3)narithmetic operators:+,-,*,/29精选课件/2.5.cpp input and output#include using namespace std;/A program to investigate the behavior of the mod(%)operation.int main()int a,b;cout ;cin a;cout ;cin b;cou

18、t a%b =a%b endl;return 0;3030精选课件Think about:o17/3=5?o5/9=0?oint n;n%2+(n+1)%2=?on=2;n+;n=n+1on=2:n+;n-;+n;-n;or=2;m=-n;p=r+;om=10,n=100;op=(n+n,n*n,n-2);op=n+n,n*n,n-2;3131精选课件Think about:oint i=2;o(i+)+(i+)+(i+);couti;oi=2;o(-i)+(-i);couti;oi=2;oi=(i+i+i);couti;oi=2;oi=(i-i);couti;32精选课件/2.6.cpp S

19、tring input#include#include using namespace std;int main()cout first second;string name=first+second;cout Hello,name n;333333精选课件Think about:the output?int x,y;x=10;y=x+;cout y endl;int a,b;a=10;b=+a;cout b 2)falsen(x y)&(y 0)truen(x 0)falsen(x 0)true363636精选课件Think aboutoint a,b,c,d,k=1,h=0;oa=!k&h

20、h+=k;ob=kh&!h+=!k|1&h;oc=h&k!=!h|!(k&h)=h+55|(h=(k=(h=3)*5)*2-+k);373737精选课件3838Statementsoa=b;odouble d2=2.5;oif(x=2)y=4;owhile(true)cout“hello”;ofor(int i=0;i8;i+)cout 0.0)return(int)(x+1.0);else return(int)x;4040精选课件To be continued41精选课件3、C+programmingControl statements42精选课件Conditions1 if(condi

21、tion)/do thisvoid main()int x;cin x;if(x0)x=-x;cout x;coutsqrt(x);43精选课件/bool leapyear(int y)/*any year divisible by 4 except centenary years not divisible by 400*/bool leapyear(int y)/any year divisible by 4 except centenary years not divisible by 400if(y%4)return false;if(y%100=0&y%400)return fals

22、e;return true;44精选课件Conditions2 if(condition)/do thiselse /do thatif(x0)cout-x;else coutb)cout a;else cout b;45精选课件Example void main()char a;couta;if(a=a&a=A&a96)a-=32;else a+=32;coutb)if(bc)coutabc)coutacb;else coutcac)coutbac)coutbca;else coutcb0 y=f(x)=0 x=0 -1 x0)k=1;else if(x=0)k=0;else k=-1;co

23、utx y)?x:y;oGet the max one of a and bint max(int a,int b)int m=a b?a:b;return m;49精选课件if(condition)/do this else if(condition)/do thisconditions450精选课件Switches switch(expression)case i:/do this break;case j:/do that break;default:/do other thing51精选课件Switch example#include using namespace std;int m

24、ain()int x=6;switch(x)case 1:cout x is 1n;break;case 2:case 3:cout x is 2 or 3;break;default:cout x is not 1,2,or 3;return 0;52精选课件/weekdayvoid weekday(int d)switch(d)case 7:cout Sunday;break;case 1:cout Monday;break;case 2:cout Tuesday;break;case 3:cout Wednesday;break;case 4:cout Thursday;break;case 5:cout Friday;break;case 6:cout Saturday;break;return;53精选课件For Loops for(initializations;condition;updates)/do this again and againfor(int i=0;i 10;i+)cout i;54精选课件

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服