华中科技大学标准C语言程序设计及应用习题答案Word文档下载推荐.docx
- 文档编号:18128774
- 上传时间:2022-12-13
- 格式:DOCX
- 页数:39
- 大小:21.96KB
华中科技大学标准C语言程序设计及应用习题答案Word文档下载推荐.docx
《华中科技大学标准C语言程序设计及应用习题答案Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《华中科技大学标准C语言程序设计及应用习题答案Word文档下载推荐.docx(39页珍藏版)》请在冰豆网上搜索。
程序2
第三章
一.填空题
=6
3.
(1)scanf("
%c"
&
c);
(2)c-32更好的答案:
c-('
a'
-'
A'
)
main()
{
inta,b;
printf("
pleaseinputa&
b:
"
);
scanf("
%d%d"
a,&
b);
\nmaxis%d\n"
(a>
b)a:
}
intmax(intx,inty);
main()
inta,b,c,max;
b&
c:
%d%d%d"
b,&
max=a>
ba:
b;
max=c>
maxc:
max;
max);
inti=0,sum=0;
while(i<
=100)
{
sum+=i;
i++;
}
printf("
1+2+3+......+100=%d\n"
sum);
inti;
inta=10,b=-3;
intc;
%6d%6d"
a,b);
for(i=2;
i<
10;
i++)
c=3*b+a;
%6d"
c);
a=b;
b=c;
\n"
while
(1)
pleaseinputadata(0:
exit):
scanf("
%d"
i);
if(i==0)
break;
if(i%2==0)
thedata%disaevennumber.\n"
i);
else
thedata%disaoddnumber.\n"
#include<
inta=8,b=1;
intsum=0;
for(i=0;
b+=3;
sum+=a;
a+=b;
a%8db:
%8d\n"
TheSumOfIs:
%d\n"
floatx,y;
pleaseinputx:
%f"
x);
if(x<
y=x;
elseif(x<
10)
y=2*x-1;
y=3*x-11;
y=%f\n"
y);
longa,i,b,a1;
pleaseinputdata(1-99999):
%ld"
a);
a:
%ld\n"
a);
if(a<
=0||a>
=100000)
i=0;
a1=0;
while(a!
=0)
b=a%10;
%8d"
b);
a/=10;
a1=a1*10+b;
\ni:
%lda1:
i,a1);
inta,b,i,k=0;
randomize();
a=random(1001);
/*createarandomdata(0-1000)*/
20;
pleaseguessanumber:
if(a>
b)
k++;
\n%d:
Smaller,guessagain!
k);
elseif(a<
Bigger,guessagain!
\nYouguessright,congraturation!
);
\nYouhaveguessed%dtimes"
if(k==20)
\nsorry,youfailed!
inta,b,c;
intnum;
for(a=0;
a<
a++)
for(b=0;
b<
b++)
for(c=1;
c<
c++)
num=a*100+b*10+c;
if((num%3==0)&
&
(a==5||b==5||c==5))
num);
\n\n\n"
inta,b;
pleaseinputa,b:
for(i=a<
i>
0;
i--)
if(a%i==0&
b%i==0)
Themax=%d"
for(i=a>
if(i%a==0&
i%b==0)
\nThemin=%d"
inta,k=0;
pleaseinputdata:
while(a%2==0)
a=a/2;
\nthenumberoffactor
(2)is%d"
longi,t=1;
longsum=0;
for(i=1;
=10;
t*=i;
sum+=t;
%ld!
=%ld\n"
i,t);
sum:
voidmain()
inti,x=0;
for(i=9;
=1;
x=2*(x+1);
Thefirstday:
x);
#definePI
floatr,h;
floatv;
pleaseinputr,h:
%f%f"
r,&
h);
v=3*PI*r*r*h;
V=%.2f"
v);
#include<
longintsn=0;
longintm=0,t=0;
inta,n,i;
pleaseinputan:
n);
n;
m=m*10+a;
sn+=m;
a+aa+aaa+...+aa...a=%ld\n\n"
sn);
intk;
pleaseinputk:
do
k);
if(k>
=0&
k<
=6)
}while
(1);
switch(k)
case0:
Sunday.\n"
break;
case1:
Monday.\n"
case2:
Tuesday.\n"
case3:
Wednesday.\n"
case4:
Thursday.\n"
case5:
Friday.\n"
case6:
Saturday.\n"
doublex,a,b=1,sum=1;
%lf"
a=x;
a/b>
=1e-6;
sum=sum+a/b;
a=a*x;
b=(i+1)*b;
\nsum=%lf"
floata,x1,x2;
inputa:
x1=;
x2=2*(x1+a/x1);
if(fabs(x2-x1)<
1e-5)
x1=x2;
sqrt(a)=%f"
x2);
第四章
写出下列程序输出结果
1a=1no1a=0no1a=1no1a=0
2.
a=0b=0c=0
a=1b=0c=0
a=2b=0c=0
3.
main:
x=5,y=1,n=1
func:
x=6,y=21,n=11
x=5,y=1,n=11
x=8,y=31,n=21
第五章
6.
(1)j+=2
(2)a[i]<
a[j]
7.
(1)s[i++]!
='
\0'
(2)s[i-1]
(同题4)
[i]>
0'
s[i]<
9'
12.
(1)'
(2)str1[i]-str2[i]
intfun();
intfun()
inta[3][3],sum;
inti,j;
sum=0;
/*error*/
3;
for(j=0;
j<
j++)
a[i][j]);
sum=sum+a[i][i];
sum=%d\n"
fun();
voidmain(void)
floatNum[10];
floatInput,GetNum[11];
floata=6;
for(i=0;
i<
i++)
Num[i]=a;
a=a+;
Loop1:
PleaseinputaNumber(0-80)Input="
Input);
if((Input<
0)||(Input>
70)==1)
gotoLoop1;
i++)
if(Input<
Num[i])
gotoLoop2;
Loop2:
j<
i;
j++)
GetNum[j]=Num[j];
GetNum[j]=Input;
for(j=i;
j++,i++)
GetNum[j+1]=Num[i];
for(j=0;
11;
%"
GetNum[j]);
#include"
inta1,a2,a3,a4,a5,a6,a7,a8,a9;
inta[3];
for(;
;
for(i=0;
{
a[i]=rand()%3;
}
while((a[0]!
=a[1])&
(a[0]!
=a[2])&
(a[1]!
=a[2]))/*getthreedifferentnumbers0,1,2*/
a1=a[0]+1;
/*divide1~9intothreegroups,a1~a3,a4~a6,a7~a9*/
a2=a[1]+1;
a3=a[2]+1;
a4=a1+3;
a5=a2+3;
a6=a3+3;
a7=a1+6;
a8=a2+6;
a9=a3+6;
/*makesurethateachlineandeachrowismadeupwiththreemembersindifferentgroup.*/
/*suchas:
a9a1a5
a2a6a7
a4a8a3*/
if(((a1+a5+a9)==(a2+a6+a7))&
((a1+a5+a9)==(a3+a4+a8))
&
((a1+a6+a8)==(a5+a7+a3))&
((a1+a5+a9)==(a2+a4+a9)))
{
printf("
%d%d%d\n%d%d%d\n%d%d%d\n"
a9,a1,a5,a2,a6,a7,a4,a8,a3);
return;
}
voidmain(void)
charinput1[100],input2[100],input3[100];
inti,Eng=0,eng=0,num=0,blank=0,other=0;
Input3rowsofcharacter,eachrowdon'
texceed80characters:
gets(input1);
Thesecondrow:
gets(input2);
Thethirdrow:
gets(input3);
/*testthefirstrow*/
100;
if(input1[i]=='
gotoLoop1;
elseif(('
=input1[i])&
(input1[i]<
Z'
)==1)
Eng++;
z'
eng++;
num++;
elseif(input1[i]==32)
blank++;
elseother++;
/*testthesecondrow*/
if(input2[i]=='
gotoLoop2;
=input2[i])&
(input2[i]<
elseif(input2[i]==32)
/*testthethirdrow*/
if(input3[i]=='
gotoLoop3;
=input3[i])&
(input3[i]<
elseif(input3[i]==32)
Loop3:
Upperenglishcharacter:
%d\nLowerenglishcharacter:
%d\nNumber:
%d\nBlank:
%d\nOthercharacters:
Eng,eng,num,blank,other);
charstr1[80],str2[40];
inti,j,k;
/*Inputtwostring*/
Pleaseinputthefirststring\nstr1="
gets(str1);
Pleaseinputthesecondstring\nstr2="
gets(str2);
/*Gettheendofstr1*/
80;
if(str1[i]=='
/*Copystr2tostr1*/
for(j=i,k=0;
str2[k]!
k++,j++)
str1[j]=str2[k];
str1[i+k]='
puts(str1);
structstudent
{charname[20];
intscore;
}stu[5],stu1;
{inti,j;
Inputstudent'
sscoreandname(5),seperateusingthecharacterof'
'
:
5;
%d,%s"
stu[i].score,&
stu[i].name);
/*sorting*/
4-i;
j++)
if(stu[j].score>
stu[j+1].score)
{stu1=stu[j];
stu[j]=stu[j+1];
stu[j+1]=stu1;
Aftersotred,scoreandname:
for(i=0;
printf("
%d,%s\n"
stu[i].score,stu[i].name);
{inta[3][3],i,j,m,n,o,p;
Pleaseinputa3*3shuzu:
for(i=0;
=2;
for(j=0;
{m=(a[i][0]>
a[i][1])a[i][0]:
a[i][1];
n=(m>
a[i][2])m:
a[i][2];
{o=(a[0][j]<
a[1][j])a[0][j]:
a[1][j];
p=(o<
a[2][j])o:
a[2][j];
if(n==p)
Andianis%d\\n"
p);
Thereisnoandian.\\n"
{inta[4][3],b[3][4],i,j;
4;
{for(j=0;
%5d"
a[i][j]);
b[j][i]=a[i][j];
b[i][j]);
{charstr[6];
inti,j=0,m=0,n=0;
gets(str);
while(str
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 华中科技大学 标准 语言程序设计 应用 习题 答案
![提示](https://static.bdocx.com/images/bang_tan.gif)