c语言部分答案Word格式文档下载.docx

上传人:b****5 文档编号:19443001 上传时间:2023-01-06 格式:DOCX 页数:15 大小:38.43KB
下载 相关 举报
c语言部分答案Word格式文档下载.docx_第1页
第1页 / 共15页
c语言部分答案Word格式文档下载.docx_第2页
第2页 / 共15页
c语言部分答案Word格式文档下载.docx_第3页
第3页 / 共15页
c语言部分答案Word格式文档下载.docx_第4页
第4页 / 共15页
c语言部分答案Word格式文档下载.docx_第5页
第5页 / 共15页
点击查看更多>>
下载资源
资源描述

c语言部分答案Word格式文档下载.docx

《c语言部分答案Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《c语言部分答案Word格式文档下载.docx(15页珍藏版)》请在冰豆网上搜索。

c语言部分答案Word格式文档下载.docx

100)

{

printf("

输入有误,请重输入:

"

);

scanf("

}

b=a/10;

switch(b)

case10:

case9:

c='

A'

;

break;

case8:

B'

case7:

C'

case6:

D'

case5:

case4:

case3:

case2:

case1:

case0:

E'

%c\n"

c);

注意用switch语句时,括号内必须是整数类型(字符型)

第四章10题

floata1=0.1,a2=0.075,a3=0.05,a4=0.03,a5=0.015,p,s,s1,s2,s3,s4,s5;

intn;

s1=100000*a1;

s2=s1+100000*a2;

s3=s2+200000*a3;

s4=s3+200000*a4;

s5=s4+400000*a5;

%f"

s);

n=s/100000;

if(n>

10)

p=s5+(s-1000000)*a1;

switch(n)

p=s*a1;

p=(s-100000)*a2+s1;

p=(s-200000)*a3+s2;

p=(s-400000)*a4+s3;

p=(s-600000)*a5+a4;

%8.2f"

p);

第五章5题

#defineA2

intn,i;

doublesum=0,term=0;

n);

for(i=1;

i<

=n;

i++)

term=10*term+A;

sum=term+sum;

%.2lf"

sum);

第五章13题

math.h>

floata,x0,x1;

x0=a/2;

x1=(x0+a/x0)/2;

while(fabs(x0-x1)>

=1e-5)

x0=x1;

x1=(x0+a/x0)/2;

%8.5f\n"

x1);

第六章9题

#defineN15

voidmain()

inti,n,t,b,m,l,a[N],f=1,s;

a[0]);

i=1;

while(i<

N)

a[i]);

if(a[i]>

a[i-1])

i++;

else

printf("

输入有误重输入:

\n"

for(i=0;

N;

a[i]);

while(f)

s=0;

t=0;

b=N-1;

if((n<

a[0])&

&

(n>

a[N-1]))

l=-1;

while((!

s)&

(t<

=b))

{

m=(b+t)/2;

if(n==a[m])

{

l=m;

printf("

%d%d"

n,l+1);

s=1;

}

elseif(n<

a[m])

b=m-1;

else

t=m+1;

}

if(!

s||l==-1)

n);

scanf("

%c"

c);

if(c=='

N'

||c=='

n'

f=0;

14题

inti,s;

chars1[100],s2[100];

gets(s1);

gets(s2);

i=0;

while((s1[i]==s2[i])&

(s1[i]!

='

\0'

))

i++;

if(s1[i]=='

s2[i]=='

s=0;

else

s=s1[i]-s2[i];

s);

第七章4题

#defineN3

inta[N][N];

voidh(inta[][3]);

inti,j;

for(j=0;

j<

j++)

a[i][j]);

%5d"

a[i][j]);

h(a);

voidh(inta[][3])

inti,j,t;

for(j=i+1;

t=a[i][j];

a[i][j]=a[j][i];

a[j][i]=t;

第七章18题

ints(int,int);

intl(intyear);

intyear,month,day,days;

%d%d%d"

year,&

month,&

day);

days=s(month,day);

if(l(year)&

month>

=3)

days=days+1;

%d\n"

days);

ints(intmonth,intday)

intd[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

inti;

month;

day+=d[i];

return(day);

intl(intyear)

intl;

l=year%4==0&

year%100!

=0||year%400==0;

return(l);

第八章4题

voidb(int[20],int,int);

inta[20],n,m,i;

n;

m);

b(a,n,m);

%d"

voidb(intc[20],intn,intm)

int*p,e;

e=*(c+n-1);

for(p=c+n-1;

p>

c;

p--)

*p=*(p-1);

*c=e;

m--;

if(m>

0)b(c,n,m);

第八章12题

string.h>

voidh(char*[]);

char*p[10],str[10][20];

10;

p[i]=str[i];

%s"

p[i]);

h(p);

%s\n"

voidh(char*s[])

char*t;

9;

9-i;

if(strcmp(*(s+j),*(s+j+1))>

0)

t=*(s+j);

*(s+j)=*(s+j+1);

*(s+j+1)=*t;

第九章1题

struct

intyear;

intmonth;

intday;

}date;

inti,days;

intday[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

date.year,&

date.month,&

date.day);

days=0;

date.month;

days=days+day[i];

days=days+date.day;

if((date.year%4==0&

date.year%100!

=0||date.year%400==0)&

date.month>

%d/%disthe%dthdayin%d.\n"

date.month,date.day,days,date.year);

附加题1

intN,M,K,i;

inta,j=0;

N,&

M,&

K);

for(i=N;

M;

if((a=i%K)!

=0)

j++;

i);

if(j%5==0)

附加题2#include<

chara[7][7]={{'

#'

'

},{'

'

}};

7;

附加题3

inta(char);

intl(char[]);

charb[100];

gets(b);

for(i=l(b);

a(b[i]);

b[i]);

inta(charc)

if((c>

a'

c<

z'

)||(c>

return

(1);

return(0);

intl(chars[])

intlen=0,i,length=0,flag=1,place=0,point;

=strlen(s);

if(a(s[i]))

if(flag)

point=i;

flag=0;

len++;

flag=1;

if(len>

=length)

{

length=len;

place=point;

len=0;

}

return(place);

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工程科技 > 能源化工

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1