模拟程序改错题(附参考答案)

模拟程序改错题(附参考答案)
模拟程序改错题(附参考答案)

1、在考生文件夹下的给定程序modi7.c中,函数fun的功能是:计算并输出k以内最大的10个能被13或17整除的自然数之和。k的值由主函数传入,若k的值为500,则函数值为4622。

请改正程序中的错误,使它能得出正确的结果。

注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!

#include

#include

#include

int fun(int k)

{int m=0,mc=0,j;

while ((k>=2)&&(mc<10))

/************found************/

{ if ((k%13=0)||(k%17=0))

{m=m+k;mc++;}

k--;

}

return m;

/************found************/

_____

main()

{system("cls");

printf("%d\n",fun(500));

}

{ if ((k%13 == 0)||(k%17 == 0))

{ if (k%13 == 0||k%17 == 0)

{ if ((k%13) == 0||(k%17) == 0)

{ if (!(k%13)||!(k%17))

{ if ((k%17 == 0)||(k%13 == 0))

{ if (k%17 == 0||k%13 == 0)

{ if ((k%17) == 0||(k%13) == 0)

{ if (!(k%17)||!(k%13))

{ if(!((k%13)&&(k%17)))

}

2、在考生文件夹下的给定程序modi13.c中,函数fun的功能是:根据整型形参m的值,计算如下公式的值。

1 1 1

t=1- ── - ── - …… - ──

2×2 3×3 m×m

例如:若m中的值为:5,则应输出: 0.536389。

请改正程序中的错误,使它能得出正确结果。

注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!

#include

#include

#include

double fun(int m)

{double y=1.0;

int i;

/************found************/

for (i=2;i

/************found************/

y-=1/(i*i);

return(y);

}

main()

{int n=5;

system("cls");

printf("\nThe result is %lf\n",fun(n));

}

for(i=2;i<=m;i++)

for(i=2;i

for(i=2;i<(m+1);i++)

for(i=2;i<1+m;i++)

for(i=2;i<(1+m);i++)

for(i=2;i<=m;++i)

for(i=2;i

for(i=2;i<(m+1);++i)

for(i=2;i<1+m;++i)

for(i=2;i<(1+m);++i) for(i=2;i<=m;i=i+1) for(i=2;i

for(i=2;i<(1+m); i=i+1) for(i=2;i<=m;i+=1)

for(i=2;i

for(i=2;i<(1+m); i+=1) for(i=2;i<=m;i=1+i)

for(i=2;i

y-=1.0/(i*i);

y=y-1.0/(i*i);

y=-1.0/(i*i)+y;

y-=1./(i*i);

y=y-1./(i*i);

y=-1./(i*i)+y;

y-=(float)1/(i*i);

y=y-(float)1/(i*i);

y=-(float)1/(i*i)+y;

y-=(double)1/(i*i);

y=y-(double)1/(i*i);

y=-(double)1/(i*i)+y;

y-=1/(1.0*i*i);

y=y-1/(1.0*i*i);

y=-1/(1.0*i*i)+y;

y-=1/((float)i*i);

y=y-1/((float)i*i);

y=-1/((float)i*i)+y;

y-=1/((double)i*i);

y=y-1/((double)i*i);

y=-1/((double)i*i)+y;

3、在考生文件夹下的给定程序modi57.c中,函数fun的功能是:将字符串tt中的小写字母改为对应的大写字母,其它字符不变。

例如,若输入"Ab,cD",则输出"AB,CD"。

请改正程序中的错误,使它能得出正确结果。

注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!

#include

#include

#include

#include

char *fun(char tt[])

{

int i;

for(i=0;tt[i];i++)

/************found************/

if(('a'<=tt[i])||(tt[i]<='z'))

/************found************/

tt[i]+=32;

return(tt);

}

main()

{

int i;

char tt[81];

system("cls");

printf("\nPlease enter a string:");

gets(tt);

printf("\nThe result string is:\n%s",fun(tt));

}

if(('a'<=tt[i])&&(tt[i]<='z'))

if((tt[i]>='a')&&(tt[i]<='z'))

if(('a'<=tt[i])&&('z'>=tt[i]))

if((tt[i]>='a')&&('z'>=tt[i]))

tt[i]-=32;

tt[i]+='A'-'a';

tt[i]-='a'-'A';

tt[i]+=-'a'+'A';

tt[i]=tt[i]-32;

tt[i]=tt[i]+'A'-'a';

tt[i]=tt[i]-'a'-'A';

tt[i]=tt[i]-'a'+'A';

4、在考生文件夹下的给定程序modi71.c中,fun函数的功能是:根据形参m,计算如下公式的值。

1 1 1 1

t = 1 + ─ + ─ + ─ +……+ ─

2 3 4 m

例如,若输入5,则应输出2.283333。

请改正程序中的错误或在横线处填上适当的内容并把横线删除,使它能得出正确结果。

注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!

#include

#include

#include

double fun(int m)

{

double t=1.0;

int i;

for (i=2;i<=m;i++)

/************found************/

t+=1.0/k;

/************found************/

_______

}

main()

{

int m;

system("cls");

printf("\nPlease enter 1 integer number:");

scanf("%d",&m);

printf("\nThe result is %lf\n",fun(m));

}

t+=1.0/i;

t=t+1.0/i;

t=1.0/i+t;

t+=1.00/i;

t=t+1.00/i;

t=1.00/i+t;

t+=1./i;

t=t+1./i;

t=1./i+t;

t+=(float)1/i;

t=t+(float)1/i;

t=(float)1/i+t;

t+=1/(float)i;

t=t+1/(float)i;

t=1/(float)i+t;

t+=(float)1/(float)i;

t=t+(float)1/(float)i;

t=(float)1/(float)i+t;

t+=(double)1/i;

t=t+(double)1/i;

t=(double)1/i+t;

t+=1/(double)i;

t=t+1/(double)i;

t=1/(double)i+t;

t+=(double)1/(double)i;

t=t+(double)1/(double)i;

t=(double)1/(double)i+t;

return t;

return (t);

5、在考生文件夹下的给定程序modi84.c中,函数fun的功能是:判断一个整数m是否是素数,若是返回1,否则返回0。

在main()函数中,若fun返回1,输出YES,若fun返回0,输出NO!。

请改正程序中的错误,使它能得出正确结果。

注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!

#include

#include

#include

int fun(int m)

{ int k=2;

while (k<=m&&(m%k))

/************found************/

k++

/************found************/

if (m=k)

return 1;

else return 0;

}

main()

{int n;

system("cls");

printf("\nPlease enter n:");scanf( "%d",&n);

if (fun(n)) printf("YES\n");

else printf("NO!\n");

}

k++;

++k;

k=k+1;

k+=1;

k=1+k;

if(m==k)

if(k==m)

if(m-k==0)

if(k-m==0)

if((m-k)==0)

if((k-m)==0)

if(!(m-k))

if(!(k-m))

6、考生文件夹下的给定程序modi100.c中函数 fun 的功能是:输入两个双精度数,函数返回它们的平方根的和。例如输入:22.993612 和84.57629812,输出为:y = 13.991709。

请改正 fun 函数中的错误,使它能得出正确的结果。

注意:不要改动 main 函数,不得增行或删行,也不得更改程序的结构!

#include

#include

#include

#include

/**********found**********/ double fun(double *a, *b)

{ double c;

/**********found**********/

c = sqrt( a ) + sqrt( b );

return c;

}

main ( )

{ double a, b, y;

system("cls");

printf ( "Enter a, b : ");

scanf ("%lf%lf", &a, &b );

y = fun (&a, &b);

printf ("y = %f \n", y );

}

double fun(double *a, double *b) c=sqrt(*a)+sqrt(*b);

c=sqrt(*b)+sqrt(*a);

c语言程序改错题

程序改错------------------------------------- 1题目:在一个一维整型数组中找出其中最大的数及其下标。 程序中共有4条错误语句,请改正错误。 -----------------*/ #define N 10 /**********FOUND**********/ float fun(int *a,int *b,int n) { int *c,max=*a; for(c=a+1;cmax) { max=*c; /**********FOUND**********/ b=c-a;} return max; } main() { int a[N],i,max,p=0; printf("please enter 10 integers:\n"); for(i=0;ix[i+1]) { t=x[j];x[j]=x[j+1];x[j+1]=t;} } main() { int i,n,a[100]; printf("please input the length of the array:\n"); scanf("%d",&n); for(i=0;ij;j++) 或 for(j=0;jj;j++) 3 if(x[j]>x[j+1]) 或 if(x[j+1]

计算机专业模拟试卷(程序填空和程序改错)

一、程序填空 1、有学生表ST,其中“编号”(N,2,0) 字段值从1开始连续排列。以下程序欲 按编号1,9,17,25……的规律抽取学 生参加比赛,并在屏幕上显示参赛学生 的编号,请填空。 USE ST DO WHILE NOT EOF() IF MOD__________ ??编号 ENDIF SKIP ENDDO 2、通过键盘输入读者的借书证号,在“读 者”表和“借阅”表中查找该读者及借 书的有关信息。 OPEN DATABASE BOOKS DO WHILE ___________ ACCEPT”请输入借书证号:” TO ZH SELECT * FROM 读者,借阅WHERE 读者.借书证号=借阅.借书证号AND ; 读者.借书证号=ZH WAIT“继续查询(Y/N)?”TO YN IF UPPER(Y/N)<>“Y” _______________________ ENDIF ENDDO _______________________ 3、将“借阅”表中借书日期超过一年且还 没有归还的记录的“标记”字段填充“*”。USE 借阅 DO WHILE _________ IF 还书日期={/} AND DA TE()—借书日期>365 REPLACE ___________ ENDIF SKIP ENDDO USE RETURN 4、一个自定义函数FX,计算F(X) =EX+3X+10的值,并编写一个主程序调 用FX函数,分别计算变量X由5到10 (步长为1)的函数值 *FX.PRG FOR I=5 TO 10 ?“X=”,I,“F(X)=”,_________ NEXT RETURN FUNCTION FX(X) ________________ RETURN F 5、下列程序根据输入的学生成绩,来判断 学生成绩等级,其中成绩大于或等于90分 的为优秀,75-90的为良好,60-74为及格, 小于60分的为不及格,请正确补充程序运 行。 Clear Set talk off ____________(“请输入成绩:”) to cj Do case Case cj<60 Dj=”不及格” Case cj<75 Dj=”及格” Case cj<90 Dj=”良好” ____________ Dj=”优秀” Endcase ? Dj Set talk on 6、设表STU.DBF中有“学号、姓名、性别、 出生日期、班级”等字段,程序完成根据姓 名进行的查询: Set talk off Use stu Store space(6) to xm Index on 学号to xh accept “输入姓名:” to xm locate for 姓名=xm display else ?“查无此人” Endif Wait “继续吗?”to yn If upper(yn)=”N” Exit Else Loop Endif Enddo Use Set talk off 7、请阅读下列判断一个自然数是否为质数 的程序,并将程序填空完整. Set talk off Input”请输入一个大于1的自然数:” to n K=0 &&K的值为0表示所输入的自然数是 质数, 为1表示不是质数 j=2 Do while j

2019届高考英语(通用版)二轮复习短文改错专题训练:训练1 短文改错(Ⅰ)(含解析)

专题五短文改错 训练1 短文改错(Ⅰ) A (2019·东北三省四市一模) One of my happiest childhood memories were having dinner with my parents and two sisters.As a result, found that we seldom had a chance to get together, then we decided we would set aside three evenings the week for a sit-down dinner.First we tried setting three fixed days for our experiment—Mondays, Wednesdays or Fridays.After a couple of week of trying this plan, almost everyone was unhappy.For a while, the kids began to resist the idea.They said they would rather to spend the time with their friends or take part in some activities.Gradual, though, they began to see these evenings together for a very different way.We laughed a lot and we discussed about each other's problems.Since a few months, we all felt that we had been able to build much strong relationships with the family than we had before. 【答案】 One of my happiest childhood memories were was/is having dinner with my parents and two sisters.As a result, ∧ having found that we seldom had a chance to get together, then we decided we would set aside three evenings the a week for a sit-down dinner.First we tried setting three fixed days for our experiment—Mondays, Wednesdays or and Fridays.After a couple of week weeks of trying this plan, almost everyone was unhappy.For a while, the kids began to resist the idea.They said they would rather ﹨to spend the time with their friends or take part in some activities. Gradual Gradually, though, they began to see these evenings together for in a very different way.We laughed a lot and we discussed about each other's problems.Since After a few months, we all felt that we had been able to build much strong stronger relationships with the family than we had before. B (2019·河北唐山一模) A new police officer was out for his first ride in a police car with a experienced partner.A call came in told them to break up a crowd of people.The officers drove to the street and observe a

C语言程序改错及填空题

下列程序是建立一个包含学生有关数据的单向链表。但该程序有2个错误,错误出现在每个注释行附近,请调试改正。调试改正中,不得改变程序结构,也不得增删语句。 #define NULL 0 struct stud { long num; char name[10]; float score; struct stud *next; }; /* …………… comment …………… */ int n; struct stud create() 序中有两处错误代码,请改正.注意,不得改变程序结构。 #include <> main() { int a[8],*p=a; int i,j; int tempmin,tempcode; printf("\n input the numbers:\n"); for (i=0;i<8;i++) scanf("%d",p+i);

tempmin=*p; for (i=0;i<7;i++) { for (j=i;j<8;j++) if (j==i||*(p+j)

c语言程序改错

【程序改错】 1.功能:利用递归函数调用方式,将所输入的5个字符,以相反顺序 打印出来。 char next; next=getchar(); palin(n-1); 2.功能:求广义菲玻那契级数的第n项。广义菲玻那契级数的前n 项为: 1,1,1,3,5,9,17,31,…… 项值通过函数值返回 main ( )函数。 例如:若 n = 15,则应输出:The value is: 2209。 for (k=4; k<=n; k++) a=b; return d; 3.功能:根据整型形参m,计算如下公式的值: y=1/2+1/8+1/18+...+1/2m*m double y=0.0; 4.功能:编制统计营业员一天的营业额的程序,设程序采用一个循环 实现,每次循环输入一笔交易金额并累计营业额。由于营 业员一天完成的交易次数是不确定的,为此以最后附加输 入一笔0或负数交易额作为交易金额已全部输入结束的标志。 float sale,sigma; scanf("%f",&sale); sigma=sigma+sale; 5.功能:读取7个数(1-50)的整数值,每读取一个值,程序打印出该值个数的*。while(n<8) while(a<1||a>50); for(i=0;i

2016年高考英语真题分类汇编:专题09-短文改错(解析版)

2016年高考试题分项解析之专题9短文改错 1.【2016·全国新课标I】短文改错(10 分) 假定英语课上老师要求同桌之间交换修改作文,请你修改你同桌写的以下作文。 文中共有10处语言错误,每句中最多有两处。每处错误仅涉及一个单词的增加、删除或修改。 增加:在缺词处加一个漏字符号( ),并在其下面写出该加的词。 删除:把多余的词用斜线()划掉。学科&网 修改:在错的词下划一横线,并在该词下面写出修改后的词。 注意:1.每处错误及其修改均仅限一词; 2.只允许修改10处,多者(从第11处起)不计分。 My uncle is the owner of a restaurant close to that 1 live .Though not very big ,but the restaurant is popular in our area .It is always crowded with customers at meal times .Some people even had to wait outside My uncle tells me that the key to his success is honest. Every day he makes sure that fresh vegetables or high quality oil are using for cooking. My uncle says that he never dreams becoming rich in the short period of time. Instead, he hopes that our business will grow steady. 【答案】 1. that →where 2. but去掉 3. had →have 4. honest→ honesty 5. or→ and 6. using →used 7. becoming前加of 8. the →a 9. our→ his 10. stead→steadily 【归纳总结】在英语中though、although、while或者as等引导的让步状语从句不和but连用;连词because不和so连用;此外,return不和back连用。 3. had →have 考查动词时态。文章是介绍现在的情况,应该用一般现在时。 4. honest→ honesty 考查名词。此处是指诚实是他成功的秘诀,用名词形式。而形容词honest 意思是“诚实的”,是指人的性格特点。

C语言程序改错2

1、以下程序的功能是求如下表达式: 1 1 1 S = 1 + ——+ ———+ ...... + ——————— 1+2 1+2+3 1+2+3+......+n 『答案』:1 scanf("%d",&n); 2 float fun(int n) 3 for(i=1;i<=n;i++) 4 s+=1.0/t 或s= s + 1.0 /t; 2、题目:函数fun的功能是:根据整型形参m的值,计算如下公式的值。 1 1 1 t = 1- ——- ——- ... - —— 2x2 3x3 mxm 例如,若m=5,则应输出:0.536389 『答案』:1 for(i=2;i<=m;i++)或for(i=2;i 2 float s=0,t=1,p=1; 3 while(fabs(t)>1e-4)或while(fabs(t)>0.0001) 4 printf("pi=%f\n", s * 4 ); 4、功能:计算正整数num的各位上的数字之积。例如,输入252,则输出应该是20。『答案』:1 long k=1; 或long int k=1; 2 num/=10; 或num=num/10; 3 scanf("%ld",&n); 4 printf("\n%ld\n",fun(n)); 5、功能:(与上题略有不同)计算正整数num的各位数字之积。例如,若输入:252,则输出应该是:20。若输入:202,则输出应该是:0。 『答案』:1 {long k=1; 2 num/=10; 或num=num/10; 3 } while(num) ; 或}while(num!=0); 或}while(num>0); 6、题目:判断m是否为素数,若是返回1,否则返回0。 『答案』:1 int fun( int m) 或fun( int m) 2 for(i=2;isqrt(i)) 4 return i; 或return (i);

专题10 备战高中高考英语短文改错-2021高考英语短文改错专项练习(解析版)

改错专项10 1.假定英语课上老师要求同桌之间交换修改作文,请你修改你同桌写的以下作文。文中共有10处语言错误,每句中最多有两处。每处错误仅涉及一个单词的增加、删除或修改。 增加:在缺词处加一个漏字符号(∧),并在其下面写出该加的词。 删除:把多余的词用斜线(\)划掉。 修改:在错的词下划一横线,并在该词下面写出修改后的词。 注意:⒈每处错误及其修改均仅限一词; ⒉只允许修改10处,多者(从第11处起)不计分。 I enjoy getting up early so I can have early start to the day.I don't like leaving my work until the last minutes.I always do the things I like least first and then do those I like them better.When I am freely, I read books or hang out with my good friends.I will tell him about it if something bothers me.To cheering me up, they often tell me jokes and help me to find a way out.I also use a good method of deal with stress.I try to go to places that I feel really relaxed, like lying on the grass on a warmth day.The method often work and makes me feel peaceful. 【答案】①early前面加an ②minutes→minute ③them 去掉④freely→free ⑤him→them ⑥cheering→cheer ⑦deal→dealing ⑧that→where ⑨warmth→warm ⑩work→works 【解析】 ①考查冠词。start可以用作名词,start用作可数名词的基本意思是“开始,出发,起点”,可指做某件事情的开始,也可指某件事情的开始地点,是可数名词。 句意:我喜欢早起,这样我就可以早点开始新的一天。start为可数名词,此处表示泛指且early为元音音素开头的单词,故early前加an。 ②考查名词。句意:我不喜欢把工作留到最后一刻。根据上文the last"最后的;最后一个"后跟单数名词,故minutes 改为minute。 ③考查代词。句意:我总是先做我最不喜欢的事,然后再做我更喜欢的事。本句为定语从句修饰those ,且作like的宾语,省略了连接词that/which。故them去掉。 ④考查形容词。句意:当我有空的时候,我读书或和我的好朋友出去玩。根据上文am可知应跟形容词作表语,故freely改为free。 ⑤考查代词。句意:如果有什么事困扰我,我会告诉他们的。此处指上文my good friends,故him 改为them。 ⑥考查非谓语动词。句意:为了让我高兴起来,他们经常给我讲笑话,帮助我想解决办法。本句为不定式作目的状语,故cheering 改为cheer。 ⑦考查非谓语动词。句意:我也用一个很好的方法来处理压力。of为介词后跟动名词做宾语,故deal 改

C语言程序改错题

第12次上机程序改错第1题 【程序改错】 -------------------------------------------------------- 功能:求二分之一的圆面积,函数通过形参得到圆的半径,函数返回二分之一的圆面积。 例如:输入圆的半径值:19.527 输出为:s = 598.950017。 ------------------------------------------------------*/ #include #include /**********FOUND**********/ double fun( r) double fun(double r) { double s; /**********FOUND**********/ s=1/2*3.14159* r * r; s=1.0/2*3.14159*r*r; /**********FOUND**********/ return r; return s; } main() { float x;

printf ( "Enter x: "); scanf ( "%f", &x ); printf (" s = %f\n ", fun ( x ) ); } 第2题【程序改错】 功能:先将在字符串s中的字符按逆序存放到t串中,然后把s中的字符按正序连接到t串的后面。 例如:当s中的字符串为:“ABCDE”时,则t中的字符串应为:“EDCBAABCDE”。 ------------------------------------------------------*/ #include #include #include void fun (char *s, char *t) { /**********FOUND**********/ int i; int sl,i; sl = strlen(s); for (i=0; i

VB程序设计例题-程序改错程序填空程序设计

'以下程序段用于输出杨辉三角:结果样式如图1 ' Private Sub Form_Click() Const n = 10 Dim arr(n, n) As Integer For I = 1 To n arr(I, I) = 1 '**********SPACE********** 【arr(I, 1) = 1】 Next I For I = 3 To n For j = 2 To I - 1 '**********SPACE********** arr(i, j) =arr(i-1,j-1)+arr(i-1,j) Next j Next I For I = 1 To n For j = 1 To I '**********SPACE********** 【print arr(I,j)】 Next j Print Next I End Sub Option Explicit '------------------------------------------------ '【程序改错】 '------------------------------------------------ '题目:用自定义函数的方法求sum(x),求当-1≤x≤1时,' sum(x)=x/2!+x^2/3!+x^3/4!+……+x^n/(n+1)!, ' 当x〉1或x〈-1时,函数值为0。当n〈=0时,输入数' 据错误。X、N都是由用户输入。 '------------------------------------------------ '注意:不可增加或删除程序行,也不可以更改程序结构 '------------------------------------------------ Private Sub Command1_Click() Dim s As Single Dim n As Integer, x As Single, k As Integer n = Val(InputBox("Please input a integer value:"))

2019届高考英语(通用版)二轮复习短文改错专题训练:训练2 短文改错(Ⅱ)(含解析)

训练2 短文改错(Ⅱ) A (2019·全国卷Ⅰ) Nearly five years before,and with the help by our father,my sister and I planted some cherry tomatoes(圣女果)in our back garden.Since then—for all these year—we had been allowing tomatoes to self-seed where they please.As result,the plants are growing somewhere.The fruits are small in size,but juicy and taste.There are so much that we often share them with our neighbors.Although we allow tomato plants to grow in the same place year after year,but we have never had any disease or insect attack problems.We are growing wonderfully tomatoes at no cost! 【答案】 Nearly five years before ago,and with the help by of our father,my sister and I planted some cherry tomatoes(圣女果)in our back garden.Since then—for all these year years—we had have been allowing tomatoes to self-seed where they please.As ∧ a result,the plants are growing somewhere everywhere.The fruits are small in size,but juicy and taste tasty.There are so much many that we often share them with our neighbors.Although we allow tomato plants to grow in the same place year after year,but 或yet we have never had any disease or insect attack problems.We are growing wonderfully wonderful tomatoes at no cost! B (2019·南昌一模) A woman was taken to the hospital.While having an operation, she had a nearly death experience.Seeing God, she asked how this was it.God said,“No, you had another 40 years.”On recovery the women decided to have a plastic surgery.She had someone change her hair color, thinking since she had so many time to live, she'd better make full use from it.Finally she got out of the hospital.While crossing the street, she killed by an ambulance speeded by.Arriving in the front of God, she demanded,“They said I had another 40 years!” God replied, “But I didn't recognize you.” 【答案】 A woman was taken to the hospital.While having an operation, she had a nearly near death experience.Seeing God, she asked how if/whether this was it.God said, “No, you had have another 40

程序改错完整版---C语言

(一)功能:用选择法对数组中的n个元素按从小到大的顺序进行排序。#include "stdio.h" #define N 20 void fun(int a[], int n) { int i, j, t, k; for (j = 0 ;j < n-1 ;j++) { /**********ERROR**********/ k = j for (i = j+1;i < n; i++) /**********ERROR**********/ if(a[i] >a[k]) /**********ERROR**********/ k=j; t = a[k] ; a[k] = a[j] ; a[j] = t; } } main() { int a[N]={9,6,8,3,-1},i, m = 5; printf("排序前的数据:") ; for(i = 0;i < m;i++) printf("%d ",a[i]); printf("\n"); fun(a,m); printf("排序后的数据:") ; for(i = 0;i < m;i++) printf("%d ",a[i]); printf("\n"); } 【参考答案】 k = j; 【参考答案】 if(a[i] < a[k]) if(a[k] > a[i])

【参考答案】 k = i; (二)功能:求广义菲玻那契级数的第n项。广义菲玻那契级数的前n 项为: 1,1,1,3,5,9,17,31,…… 项值通过函数值返回 main ( )函数。 例如:若 n = 15,则应输出:The value is: 2209。 #include "conio.h" #include "stdio.h" long fun ( int n ) { long a=1, b=1, c=1, d=1, k; /**********ERROR**********/ for (k=4; k

程序填空、改错第二次练习

程序填空和改错练习2 一、程序填空 1. 功能:输入一个学生的生日(年:y0、月:m0、日:d0),并输入当前日期(年:y1、月:m1、日:d1)。求出该学生的年龄(实足年龄)。 #include main() {int age,y0,y1,m0,m1,d0,d1; printf("输入生日日期(年,月,日)"); /***********SPACE***********/ 【?】("%d,%d,%d",&y0,&m0,&d0); printf("输入当前日期(年,月,日)"); scanf("%d,%d,%d",&y1,&m1,&d1); age=y1-y0; /***********SPACE***********/ if(m0【?】m1)age--; /***********SPACE***********/ if((m0【?】m1)&&(d0>d1))age--; printf("age=%3d",age); } 2. 题目:对二维数组a中存储的N*N矩阵做如下操作:先将每一行中值最大的元素与该行位于主对角线处的元素交换,然后对主对角线上所有元素排序使其自左上角到右下角升序排列,最后输出排序后主对角线上各元素的值。 #include #define N 5 void fun(int x[][N],int n) { int i,j,t,arr,col; for(i=0;i=arr) {arr=x[i][j]; 【?】} t=x[i][i]; x[i][i]=x[i][col];x[i][col]=t; } for(i=0;i

高考英语短文改错专项训练(附答案解析)

高考英语短文改错专项训练(含答案) 1.【2016·全国新课标I】短文改错(10 分) My uncle is the owner of a restaurant close to that 1 live .Though not very big ,but the restaurant is popular in our area .It is always crowded with customers at meal times .Some people even had to wait outside My uncle tells me that the key to his success is honest. Every day he makes sure that fresh vegetables or high quality oil are using for cooking. My uncle says that he never dreams becoming rich in the short period of time. Instead, he hopes that our business will grow steady. 2.【2016·全国新课标II】短文改错(共10小题,每小题1分,满分10分) The summer holiday is coming. My classmates and I are talking about how to do during the holiday. We can chose between staying at home and take a trip. If we stay at home, it is comfortable but there is no need to spend money. But in that case, we will learn little about world. If we go on a trip abroad, we can broaden you view and gain knowledges we cannot get from books. Some classmates suggest we can go to places of interest nearby. I thought that it is a good idea. It does not cost many, yet we can still learn a lot. 3.【2016·全国新课标III】短文改错(共10小题;每小题1分,满分10分) The teenage year from 13 to 19 were the most difficult time for me . They were also the best and worse years in my life . At the first, I thought I knew everything and could make decisions by yourself. However, my parents didn’t seem to think such. They always tell me what to do and how to do it. At one time , I even felt my parents couldn’t understand me so I hoped I could be freely from them. I showed them I was independent by wear strange clothes. Now I am leaving home to college. At last, I will be on my own, but I still want to have my parents to turn to whenever need help. 4.【2016·四川】短文改错(共10小题;每小题1分,满分10分) It is Mother’s Day today. Though it’s a western festival, it’s popular in China now. Mom has a full-time job, so she has to do most of the houseworks. She is a great mother. Both Dad or I planned to do something on Mother’s Day. We get up early in the morning. Dad cleaned the house, and then went on shopping. When he came back, I found a bunch of flowers in her hand. I asked Mom to stay in the sitting room and I cooked in kitchen. The dishes what I cooked were Mom’s favoritiest. At dinner, we said to her, “Happy Mother’s Day!”Mom was grateful and moving.

相关文档
最新文档