c语言程序设计基础单元总结与练习题及答?- 百度文库

CԳƻγ̵Ԫܽ뵥Ԫϰ

{ int a,b,c;

scanf(\ printf(\ }

A6 Ba+b+c=6 C123 Dȷֵ

3.Уȷǣ

Ascanf(\ Bscanf(\; Cscanf(\;

Dscanf(\;

4VC++6.0У˵ȷǣ

A뺯scanf()ʱʱݼ䲻ؼӼ

B뺯scanf()еȻ˫ȸݶҪ%fΪʽƷ Cʹprintf()ַַøʽƷ%s

Dprintf()еȻ˫ȸݶҪ%fΪʽƷ 5ĹʵֵַΪch1ach2bʱȷǣ

#include void main( )

{ char ch1,ch2,ch;

scanf(\ ch=ch1;ch1=ch2;ch2=ch;

printf(\ }

Aa,b Ba<ո>b Cab Da<س>b

1.putchar(getchar()),ʱ룺A____________ 2printf(\3);____________

3 int n1=10,n2=20; printf(\ \ Ҫ¸ʽn1n2ֵÿдӵһпʼ

n1=0010 n2=0020

4.³򣬳ʱ룺1234<س>ִкĽ_________________

#include

CԳƻγ̵Ԫܽ뵥Ԫϰ

void main( ) { char ch1,ch2; int n1,n2;

ch1=getchar(); ch2=getchar(); n1=ch1-0; n2=n1*10+(ch2-0);

printf(\ }

5. ַ͵ֵʱʱ Ϊ

*******************************************************************************

ϰ𰸣

һѡ

1A

2D

3B

4A

5C

1.A 2.0.33%

3.n1=d\\nn2=d 4.n1=1,n2=12

5.ոTABس

*******************************************************************************

CԳƻγ̵Ԫܽ뵥Ԫϰ

Ԫ ѡṹ

Ԫܽ

ѡṹУжϱʽѡṹʵݡͨԪѧϰӦ֪

1жϱʽɹϵʽ߼ʽɣУ 1 ϵУ > < >= <= != == 2 ߼У &&|| 2ѡṹʵַʽ 1 ֧ifѡṹһʽΪ if ( ʽ )

{ 䣻}

2 ˫֧if-elseѡṹһʽΪ

if ( ʽ )

{ 1}

else { 2}

3 ֧ switchѡṹһʽΪ

switch( ʽ )

{ case ʽ1: [1;] [break;]

case ʽ2: [2;] [break;]

??

}

case ʽn: [n;] [break;] default: n+1;

3ӦѡṹʱӦע⣺

1ifǶУҪŪelseifƥϵдifǶʱһĽʽдʵʱУΪ˱ߵͼҲͨ{}ǿifelseԹϵ

CԳƻγ̵Ԫܽ뵥Ԫϰ

2switchУʽ͡ʽֻͻַݣҡʽֻɳɣͨʽ롰ʽ֮ĶԵȹϵ֧ѡṹ

3ijЩ֧ѡṹУȿʹif-elseʵ֣Ҳʹswitchʵ֡switchifIJ֮ͬڣswitchжһ߼ϵʽָʽֵǷȣܽдڣСijһֵжϣܱݵĸifԼжϸֱʽswitch䲻ȫif䡣

֮ͨԪѧϰӦCѡṹƵ˼·Ļ÷

Ԫϰ

һѡ

1ѡУxΪ1ʱֵΪ0ıʽ

Ax%2==1

Bx/2

Cx%2!=0

Dx%2==0

2CУifһԲһԾ֧ıʽñʽ

Aֻǹϵʽ Bֻ߼ʽ Cֻǹϵ߼ʽ DκκϷʽ 3Σx=-3ʱyֵΪ

int x,y; y=0;

scanf(%d,&x); if(x>=0) if(x>0) y=1; else y=-1;

printf(y=%d,y);

A1 B-1 C0 Dȷ 4佫СдĸתΪдĸȷΪ

Aif(z>=ch>=a) ch=ch-32; Bif(ch>=a&&ch<=z) ch=ch-32; Cch=(z>=ch>=a)?ch-32:ch;

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