全国计算机等级考试二级C语言考点(完整? - 百度文库

11. ϵ͹ϵʽ

11.1 Cе߼ֵ

Cе߼ֵֻ棨true)ͼ٣flase)÷棬١ˣһʽֵΪ㣬ʹһֵֵΪ㣬ʹһֵֻҪֵ㣬ʵһֵ-5߼ֵΪ档

11.2 ϵȴ

Cṩ6ֹϵ

ַɵ֮䲻Լӿո񣬹ϵ˫Ŀ (1)ԣҡ

(2)ȴǰ4ֹϵ( <<=>=> )ȼͬ (==!=)ȼͬǰ4ȼں֣ϵȼڸֵ

11.3 ϵʽ

ɹϵӶɵıʽΪϵʽ 磺a>b,a=7)>(b=10)ȶǺϷĹϵʽ

ϵʽĽ01,0ʾ٣1ʾ档ϵʽֵΪ棬ϵʽֵΪ١

aֵΪ5bֵΪ6ôϵʽa>bֵΪ٣Ϊ0.ϵʽ a=13)>(b=10)ֵΪ棬Ϊ1

ϵֵͲһʱһͣһʵͣϵͳԶתΪʵȻٽбȽϡ

12. ߼߼ʽ

12.1 ߼ȼ

ṩ3߼± ˵

&&͡||˫ĿҪҪǵĿֻҪһɡ߼ȼǣ!(߼)ߣǡ&&(߼)||(߼)ͣ߼еġ&&͡||ڹϵ! ߼ǣ>>ϵ>&&>||>ֵ>

12.2 ߼ʽ

&&͡||Ƕ˫ĿֻһǵĿ߼£

1a&&b: &&߶Ϊ桱ʱʽa&&bֵ档

ֵעǣѧУϵʽ0

2a||b: ||һΪ桱ʱʽa||bֵ档

3!a: ʾȡaΪ棬!AΪ٣֮Ȼ磡-5ֵΪ0.

ڣУ&&||ɵ߼ʽijЩض»·

1x && y && z ֻеxΪ(0)ʱҪбyֵֻxyΪʱҪȥбzֵֻҪxΪپͲбyzʽֵΪ0ھһٱؼ١ 5==1&&++i==0 5==1ʽֵΪ0Լо++i==0˱ʽ5==1&&++i==0ʽֵΪ0.

2x||y||z ,ֻҪxֵΪ()Ͳбyzֵ ʽֵΪ1ֻxֵΪ٣ҪбyֵֻxyֵͬʱΪٲҪбzֵھһ桱

13. λ

13.1 λ

ڼУݶԶʽŵģλָԴ洢Ԫжλ㡣Cṩ6λ

˵

1λг~⣬Ϊ˫ĿҪһ 2ֻͻַݣΪʵݡ

13.2 λ

λ & |~<< >> ȼӸߵе˳ǣ λ㡰~ȼߣƺͬڵڶ˳ǰλ &λ ġͰλ |˳Ϊ~ << >> & |

1<<˫Ŀ书ܰѡ<< ߵĸλȫλɡ<<ұߵָƶλλλ0 磺 a<<4

ָaĸλƶ4λa=00000011(ʮ3)4λΪ00110000(ʮ48) 2>>˫Ŀ书ǰѡ>> ߵĸλȫλ>>ұߵָƶλ 磺 a=15 a>>2

ʾ000001111Ϊ00000011(ʮ3)

Ӧ˵ǣзʱλͬƶΪʱλ0ΪʱλΪ1λDz0Dz1 ȡڱϵͳĹ涨

3 a00101101 ͨab ʹaĸ4λȡ4λ䣬bǡ :㳣ʹضλתֻҪʹ跭תλ1ͿˣΪԭֵΪ1λ10 ԭֵΪ0λ110λԭֵ㻹ֵʱ int a=3 , b=4뽫abֵʵ֣ a=ab; b=ba;

a=ab;

ԱĴΪ 11110000

ڶ ˳ṹ

1. C

CԵϵͳָһʵʵԴͨ䣬ЩһIJ

Cе䣬ڳгֵ˳ִУ乹ɵijṹΪ˳ṹ

1.1

(ɺüһֺŹ) scanf(%d,&a) ʽ(һʽһ) a=b

1.2

C䶼һֺţ ֻһֺmain(){;}ֺҲһ䣬Ϊ䣬ִʱκζʾһ䡣

1.3

Cлš{ }Ŀʼͽ־ͬʱҲĿʼͽ־ҲɳΪ 塱

CУκαʽԼϷֺŹ䣬 i++;ӡᵼºܶ߼ϵĴҪãҪáһķֺŲܺԲд

2. ֵ

ǰѾֵܸɸֵʽĩβķֺ ɵġҪѶע⣺=롰==ͬǰ߲ǸֵǹϵжϣܰѶ߻Ϊһ̸硰i=2;ǰֵ2ŵiУi==2жϱiֵǷΪ2j=j+1;ڳִʱȡjеִֵмֵ1IJֵٰŻصjС

3. ʵ

(1)ݴӼڲⲿ豸(ʾӡ)͵IJΪ ݴӼⲿ豸(̡ꡢɨǵ)IJΪ 롱

(2)CԱṩ䣬ͨʵIJ

(3)ʹCԿ⺯ʱҪԤ #includeйصġͷļûԴļСҪõԤں½ǻϸ

3.1 ַ

3.1.1 ַputchar()

putchar( )նһַ 磺 putchar(a);

ַaֵaҲַͱͱaͱASCIIֵΪñֵǸַ

3.1.2 ַ뺯getchar()

getchar( )ǴնһַgetcharûвֵǴ豸õַ

getchar()ֻܽһַgetchar()õַԸһַͱҲԲκαΪʽһ֡һ(Ϊmain())Ҫgetchar()putchar()ڸ֮ǰİ#include DZزٵġ

3.2 ݸʽ

3.2.1 printf()

printf( )Cṩı׼ն(ϵͳָ豸)ָʽɸݡ

a. printf()һʽ printf(ʽƣ); 磺

printf(%f,%d,x,y);

printfǺɣ (1)ʽơ˫ַǡʽơַϢ

ʽת˵ɡ%͸ʽַɣ %d%sȡУΪint ʱϵͳ涨dΪʽַˣС%dΪfloatdoubleʱfeΪʽַʽҪһһӦƥ䡣

Ҫԭַ(ָͨ˸ʽ˵һЩתַDz)Ҳдڸʽڡ (2)СҪһЩݣdzʽ磺 printf(x=%d y=%d,x,y); Уx=%d y=%dǸʽ˵ x,y СеĸҪöŸxyֵΪ78 Ϊ x=7 y=8

֮пոΪʽ˵мһո b. ʽַ

ԸҪڡ%ʽַ֮롰˵š-ǰš0ȡ (1)dʽʮС%dݵʵʳ%mdָmΪֶռĿȡ

(2)oʽ԰˽ʽͬͨ硰%8oĸʽָʱռĿȡ (3)xʽʮʽͬͨ硰xĸʽָʱռĿȡ (4)uʽ unsigned ݣ޷ŵʮ (5)cʽһַ (6)sʽһַ

(7)fʽʵ(˫)Сʽ,ʹȫ (8)eʽָʽʵ (9)gʽʵ

fegʽá1??2ʽָȵͬʱָСλλУ1ָռܿȣ2ȷȡȶڲͬĸʽŲͬĺ塣λڡ2ָĿʱȥұ߶СԽȥĵһλС봦ݵСλڡ2ָĿʱСұ0ռĿȴڡ1ָĿʱСλ԰ֲʧҲá??2ʽָСλʱռϵͳͨϵͳfloatṩ7λЧλdoubleṩ15λЧλ

c. ʹprintf()ʱע

(1)ڸʽַУʽ˵ϱһһӦƥ䣬粻ƥ佫ִlongʱһҪ%ldʽƣ%dʽơ

(2)ڸʽƴУʽ˵ĸҲҪȣʽ˵ĸĸڶĸʽֵ(0ֵ) (3)ڸʽƴУ˺Ϸĸʽ˵⣬԰ĺϷַ(תַ)Щַʱԭ

(4)Ҫ %Ӧڸʽƴİٷֺš%%ʾ

ϵͷ779662525#qq.com(#滻Ϊ@)