c语言上机模拟试题11套Microsoft Word 文档 2Word文档下载推荐.docx

上传人:b****6 文档编号:15919974 上传时间:2022-11-17 格式:DOCX 页数:68 大小:29.10KB
下载 相关 举报
c语言上机模拟试题11套Microsoft Word 文档 2Word文档下载推荐.docx_第1页
第1页 / 共68页
c语言上机模拟试题11套Microsoft Word 文档 2Word文档下载推荐.docx_第2页
第2页 / 共68页
c语言上机模拟试题11套Microsoft Word 文档 2Word文档下载推荐.docx_第3页
第3页 / 共68页
c语言上机模拟试题11套Microsoft Word 文档 2Word文档下载推荐.docx_第4页
第4页 / 共68页
c语言上机模拟试题11套Microsoft Word 文档 2Word文档下载推荐.docx_第5页
第5页 / 共68页
点击查看更多>>
下载资源
资源描述

c语言上机模拟试题11套Microsoft Word 文档 2Word文档下载推荐.docx

《c语言上机模拟试题11套Microsoft Word 文档 2Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《c语言上机模拟试题11套Microsoft Word 文档 2Word文档下载推荐.docx(68页珍藏版)》请在冰豆网上搜索。

c语言上机模拟试题11套Microsoft Word 文档 2Word文档下载推荐.docx

stdio.h>

main()

{

inti,j,m,s,k,a[100];

for(i=1;

i<

=1000;

i++)

{

m=i;

s=0;

k=0;

for(j=1;

j<

m;

j++)

/***********SPACE***********/

if(【?

】)

s=s+j;

【?

】=j;

}

if(s!

=0&

&

s==m)

for(j=0;

】;

j++)

printf("

%4d"

a[j]);

=%4d\n"

i);

}

}

答案:

=======(答案1)=======

m%j==0

=======(答案2)=======

a[k++]

=======(答案3)=======

j<

k

=========或=========

k>

j

二、程序改错共1题(共计30分)

362

/*------------------------------------------------------

【程序改错】

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

删除字符串s中的所有空白字符(包括Tab字符、回车符及

换行符)。

输入字符串时用'

#'

结束输入。

-----------------------------------------------------*/

string.h>

ctype.h>

fun(char*p)

{

inti,t;

charc[80];

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

for(i=1,t=0;

p[i];

i++)

if(!

isspace((p+i)))c[t++]=p[i];

c[t]="

\\0"

;

strcpy(p,c);

}

main()

charc,s[80];

inti=0;

inputastring:

"

);

c=getchar();

while(c!

='

{

s[i]=c;

i++;

c=getchar();

s[i]='

\0'

fun(s);

puts(s);

for(i=0,t=0;

if(!

isspace(*(p+i)))c[t++]=p[i];

c[t]='

三、程序设计共1题(共计40分)

第1题(40.0分)题号:

394

/*------------------------------------------------

【程序设计】

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

产生20个[30,120]上的随机整数放入二维数组

a[5][4]中,求其中的最小值。

------------------------------------------------*/

#include"

stdlib.h"

voidwwjt();

intamin(inta[5][4])

/**********Program**********/

/**********End**********/

main()

inta[5][4],i,j;

for(i=0;

i<

5;

i++)

for(j=0;

4;

j++)

a[i][j]=random(120-30+1)+30;

%5d"

a[i][j]);

\n"

min=%d\n"

amin(a));

wwjt();

voidwwjt()

FILE*IN,*OUT;

intm,n;

inti[5][4];

into;

IN=fopen("

in.dat"

"

r"

if(IN==NULL)

ReadFILEError"

OUT=fopen("

out.dat"

w"

if(OUT==NULL)

WriteFILEError"

for(m=0;

m<

m++)

for(n=0;

n<

n++)

fscanf(IN,"

%d"

&

i[m][n]);

o=amin(i);

fprintf(OUT,"

%d\n"

o);

fclose(IN);

fclose(OUT);

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

inti,j,s;

s=a[0][0];

if(s>

a[i][j])s=a[i][j];

return(s);

2

17

删除字符串中的指定字符,字符串和要删除的字符均由键盘

输入。

charstr[80],ch;

inti,k=0;

gets(【?

】);

ch=getchar();

【?

】;

if(str[i]!

=ch)

k++;

puts(str);

str

str[i]!

=NULL

=0

str[i]

str[k]=str[i]

*(str+k)=*(str+i)

str[k]=*(str+i)

*(str+k)=str[i]

=======(答案4)=======

str[k]='

*(str+k)='

str[k]=NULL

str[k]=0

*(str+k)=0

*(str+k)=NULL

442

写一个函数,求一个字符串的长度,在main函数中输入字

符串,并输出其长度。

------------------------------------------------------*/

conio.h>

intlength(p)

char*p;

intn;

n=0;

while(*p=='

n++;

p++;

returnn;

intlen;

char*str[20];

pleaseinputastring:

scanf("

%s"

str);

len==length(str);

thestringhas%dcharacters."

len);

while(*p!

while(*p)

=0)

=NULL)

charstr[20];

len=length(str);

三、程序设

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

当前位置:首页 > 成人教育 > 自考

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

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