c题库改错Word文档格式.docx

上传人:b****2 文档编号:6097848 上传时间:2023-05-06 格式:DOCX 页数:156 大小:55.37KB
下载 相关 举报
c题库改错Word文档格式.docx_第1页
第1页 / 共156页
c题库改错Word文档格式.docx_第2页
第2页 / 共156页
c题库改错Word文档格式.docx_第3页
第3页 / 共156页
c题库改错Word文档格式.docx_第4页
第4页 / 共156页
c题库改错Word文档格式.docx_第5页
第5页 / 共156页
c题库改错Word文档格式.docx_第6页
第6页 / 共156页
c题库改错Word文档格式.docx_第7页
第7页 / 共156页
c题库改错Word文档格式.docx_第8页
第8页 / 共156页
c题库改错Word文档格式.docx_第9页
第9页 / 共156页
c题库改错Word文档格式.docx_第10页
第10页 / 共156页
c题库改错Word文档格式.docx_第11页
第11页 / 共156页
c题库改错Word文档格式.docx_第12页
第12页 / 共156页
c题库改错Word文档格式.docx_第13页
第13页 / 共156页
c题库改错Word文档格式.docx_第14页
第14页 / 共156页
c题库改错Word文档格式.docx_第15页
第15页 / 共156页
c题库改错Word文档格式.docx_第16页
第16页 / 共156页
c题库改错Word文档格式.docx_第17页
第17页 / 共156页
c题库改错Word文档格式.docx_第18页
第18页 / 共156页
c题库改错Word文档格式.docx_第19页
第19页 / 共156页
c题库改错Word文档格式.docx_第20页
第20页 / 共156页
亲,该文档总共156页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

c题库改错Word文档格式.docx

《c题库改错Word文档格式.docx》由会员分享,可在线阅读,更多相关《c题库改错Word文档格式.docx(156页珍藏版)》请在冰点文库上搜索。

c题库改错Word文档格式.docx

"

);

scanf("

%s"

s);

fun(s,t);

\nTheresultis:

%s\n"

t);

第2题(10.0分)题号:

434

编写一个程序计算某年某月有几天。

(注意要区分闰年)

#include<

voidmain()

intyy,mm,len;

year,month="

%d%d"

&

yy,&

mm);

switch(mm)

{

case1:

case3:

case5:

case7:

case8:

case10:

case12:

len=31;

Break;

case4:

case6:

case9:

case11:

len=30;

break;

case2:

if(yy%4==0&

&

yy%100!

=0||yy%400==0)

len=29;

else

len=28;

default:

inputerror!

\n"

}

Thelengthof%d%did%d\n"

yy,mm,len);

getch();

第1题(10.0分)题号:

27

实现3行3列矩阵的转置,即行列互换。

fun(inta[3][3],intn)

{

inti,j,t;

for(i=0;

i<

n;

i++)

for(j=0;

j<

j++)

%d"

a[i][j]);

%4d"

a[i][j]);

i;

t=a[i][j];

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

a[j][i]=t;

main()

intb[3][3];

fun(b,3);

367

用插入排序法将n个字符进行排序(降序)。

提示:

插入法排序的思路是:

先对数组的头两个元素进行排序,

然后根据前两个元素的情况插入第三个元素,再插入第

四个元素…)。

#defineN81

voidfun(char*aa,intn)

inta,b,t;

for(a=1;

a<

a++)

t=aa[a];

b=a-1;

while((b>

=0)&

(t>

aa[b]))

aa[b+1]=aa[b];

b--;

aa[b+1]=t;

{chara[N];

inti;

printf("

\nEnterastring:

"

gets(a);

fun(a,strlen(a));

\nThestring:

puts(a);

getch();

408

写计算级数ex=1+x+x2/2!

+x3/3!

+...+xn/n!

的值。

#include"

stdio.h"

intm,n;

floatx,term,ex1,ex2;

x,m="

%f%d"

x,&

m);

ex1=ex2=1;

term=1;

for(n=1;

n<

=m;

n++)

term*=x/n;

ex1+=term;

ex2=term;

for(n=m;

n>

=1;

n--)

term*=n/x;

ex2+=term;

exforward=%fexbackrard=%f\n"

ex1,ex2);

第2题(10.0分)题号:

574

一个已排好序的一维数组,输入一个数number,要求按原来排序的规律将它插入数组中.

main()

inta[11]={1,4,6,9,13,16,19,28,40,100};

inttemp1,temp2,number,end,i,j;

/***********FOUND***********/

10;

%5d"

a[i]);

number);

end=a[9];

if(number>

end)

a[10]=number;

if(a[i]>

number)

temp1=a[i];

a[i]=number;

for(j=i+1;

11;

temp2=a[j];

a[j]=temp1;

temp1=temp2;

%6d"

答案:

1).for(i=0;

i++)2).end=a[9];

3).a[10]=number;

4).if(a[i]>

419

利用递归函数调用方式,将所输入的5个字符,以相反顺序

打印出来。

inti=5;

voidpalin(intn);

\40:

palin(i);

voidpalin(n)

intn;

charnext;

if(n<

=1)

next=getchar();

\n\0:

putchar(next);

palin(n-1);

1).charnext;

2).next=getchar();

3).palin(n-1);

398

使数组左下三角元素中的值乘以n。

stdlib.h>

#defineN3

intfun(inta[][N],intn)

inti;

j;

1).inti,j;

i<

N;

j<

N;

j++)2).for(j=0;

=i;

j++)

a[i][j]=*n;

3).a[i][j]*=n;

main()

inta[N][N],n,i,j;

*****Thearray*****\n"

for(i=0;

3;

for(j=0;

a[i][j]=rand()%10;

printf("

a[i][j]);

do

n=rand();

while(n>

=5||n<

1);

n=%4d\n"

n);

fun(a,n);

printf("

*****THERESULT*****\n"

382

读入一行英文文本,将其中每个单词的最后一个字母改成

大写,然后输出此文本行(这里的“单词”是指由空格

隔开的字符串)。

若输入“Iamastudenttotaketheexamination.”,

则应输出“IaMAstudenTtOtakEthEexamination.”。

#include"

conio.h"

ctype.h"

string.h"

up1st(char*p)

integerk=0;

1).intk=0;

for(;

*p;

p++)

if(k)

if(*p='

'

)2).if(*p=='

k=0;

*(p-1)=toupper(*(p-1);

3).*(p-1)=toupper(*(p-1));

少了半个括号

elseif(*p!

='

)k=1;

*(p-1)=toupper(*(p-1));

}

charchrstr[81];

\nPleaseenterastring:

);

gets(chrstr);

\n\nBeforechanging:

\n%s"

chrstr);

up1st(chrstr);

\nAfterchanging:

\n%s"

360

将长整型数中每一位上为奇数的数依次取出,构成一个新

数放在t中。

高位仍在高位,低位仍在低位。

当s中的数为:

87653142时,t中的数为:

7531。

voidfun(longs,long*t)

intd;

longsl=1;

t=0;

1).*t=0;

while(s>

0)

{

d=s%10;

if(d%2==0)2).if(d%2)或if(d%2!

=0)或if((d%2)!

=0)

*t=d*sl+*t;

sl*=10;

s\=10;

3).s/=10;

或s=s/10

longs,t;

\nPleaseenters:

%ld"

&

s);

fun(s,&

t);

Theresultis:

%ld\n"

255

以下程序把两个数按由大到小的顺序输出来.

/***********FOUND***********/

swap(int*p1,*p2)1).swap(int*p1,int*p2)或voidswap(int*p1,int*p2)

intp;

p=*p1;

*p1=*p2;

*p2=p;

inta,b,*p,*q;

inputa,b:

a,b);

2).scanf("

a,&

b);

p=&

a;

q=&

b;

if(a<

b)

swap(p,q);

a=%d,b=%d\n"

max=%d,min=%d\n"

p,q);

3).printf("

*p1,*p2);

或printf("

440

输入字符序列,字符序列以特殊字符“#”结束。

程序从前

向后依次读入字符,并翻译出新的字符输出。

翻译的规则

是:

如果当前读入的字符是数字符,如果该字符的面值为n,

则它的后一个字符(包括数字符)需重复输出n+1次如果当前

读入的字符不是数字符,则输出该字符。

输出时,以上述一

次翻译为一组,不同组间输出用一个空白字符隔开。

翻译

直至当前读入的字符为字符‘#’,结束翻译和输出。

charch,nch;

intcount;

intk;

Enterstring.\n"

%c"

ch);

while(ch='

#'

)1).while(ch!

='

if(ch>

0'

ch<

9'

count=ch-'

-1;

2).count=ch-'

+1;

nch);

for(k=0;

k<

count;

k++)

nch);

%f"

ch);

#\n"

12909

三、程序改错共2题(共计20分)

437

-------------------------------------------------------

以下程序能求出1*1+2*2+......+n*n<

=1000中满足条件的

最大的n。

intn,s;

s==n=0;

1).s=n=0;

while(s>

1000)2).while(s<

=1000)

++n;

s+=n*n;

n=%d\n"

n-1);

n-1);

410

某个公司采用公用电话传递数据,数据是四位的整数,在

传递过程中是加密的,加密规则如下:

每位数字都加上5,

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

当前位置:首页 > 总结汇报 > 学习总结

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2