C语言模拟试题完整版Word文档格式.docx

上传人:b****2 文档编号:5141295 上传时间:2023-05-04 格式:DOCX 页数:36 大小:20.70KB
下载 相关 举报
C语言模拟试题完整版Word文档格式.docx_第1页
第1页 / 共36页
C语言模拟试题完整版Word文档格式.docx_第2页
第2页 / 共36页
C语言模拟试题完整版Word文档格式.docx_第3页
第3页 / 共36页
C语言模拟试题完整版Word文档格式.docx_第4页
第4页 / 共36页
C语言模拟试题完整版Word文档格式.docx_第5页
第5页 / 共36页
C语言模拟试题完整版Word文档格式.docx_第6页
第6页 / 共36页
C语言模拟试题完整版Word文档格式.docx_第7页
第7页 / 共36页
C语言模拟试题完整版Word文档格式.docx_第8页
第8页 / 共36页
C语言模拟试题完整版Word文档格式.docx_第9页
第9页 / 共36页
C语言模拟试题完整版Word文档格式.docx_第10页
第10页 / 共36页
C语言模拟试题完整版Word文档格式.docx_第11页
第11页 / 共36页
C语言模拟试题完整版Word文档格式.docx_第12页
第12页 / 共36页
C语言模拟试题完整版Word文档格式.docx_第13页
第13页 / 共36页
C语言模拟试题完整版Word文档格式.docx_第14页
第14页 / 共36页
C语言模拟试题完整版Word文档格式.docx_第15页
第15页 / 共36页
C语言模拟试题完整版Word文档格式.docx_第16页
第16页 / 共36页
C语言模拟试题完整版Word文档格式.docx_第17页
第17页 / 共36页
C语言模拟试题完整版Word文档格式.docx_第18页
第18页 / 共36页
C语言模拟试题完整版Word文档格式.docx_第19页
第19页 / 共36页
C语言模拟试题完整版Word文档格式.docx_第20页
第20页 / 共36页
亲,该文档总共36页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

C语言模拟试题完整版Word文档格式.docx

《C语言模拟试题完整版Word文档格式.docx》由会员分享,可在线阅读,更多相关《C语言模拟试题完整版Word文档格式.docx(36页珍藏版)》请在冰点文库上搜索。

C语言模拟试题完整版Word文档格式.docx

for(i=0;

【?

】;

i++)

*(p+i)=【?

i=0;

k=0;

m=0;

while(m<

n-1)

{

if(【?

】!

=0)k++;

if(k==3)

*(p+i)=0;

m++;

}

i++;

if(i==n)i=0;

while(【?

】)p++;

%disleft\n"

*p);

return0;

}

答案:

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

i<

n

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

n>

i

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

i+1

1+i

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

*(p+i)

*(i+p)

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

*p==0

0==*p

第2题(15.0分)

输入某年某月某日,判断这一天是这一年的第几天?

intday,month,year,sum,leap;

\npleaseinputyear,month,day\n"

);

%d,%d,%d"

year,&

month,&

day);

switch(month)/*从月份得出已过多少天*/

case1:

sum=0;

break;

case2:

sum=31;

case3:

sum=59;

case4:

case5:

sum=120;

case6:

sum=151;

case7:

sum=181;

case8:

sum=212;

case9:

sum=243;

case10:

sum=273;

case11:

sum=304;

case12:

sum=334;

default:

printf("

dataerror"

【?

/*再加上日期数*/

if(year%400==0||(year%4==0【?

】)/*判断是否闰年*/

leap=1;

else

leap=0;

if(leap==1【?

】)

sum++;

itisthe%dthday."

sum);

sum=90

sum=sum+day

sum=day+sum

sum+=day

&

year%100!

=0

0!

=year%100

(year%100!

=0)

(0!

=year%100)

month>

2

2<

month

(month>

2)

(2<

month)

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

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

【程序改错】

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

请编写函数fun,对长度为8个字符的字符串,将8个字符按

降序排列。

例如:

原来的字符串为CEAedcab,排序后输出为edcbaECA。

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

#include<

ctype.h>

conio.h>

voidfun(char*s,intnum)

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

inti;

j;

chart;

num;

for(j=i;

j>

j++)

if(s[i]>

s[j])

t=s[i];

s[i]=s[j];

s[j]=t;

main()

chars[10];

输入8个字符的字符串:

gets(s);

fun(s,8);

\n%s"

s);

inti,j;

for(j=i+1;

j<

for(j=i;

if(s[i]<

if(s[j]>

s[i])

以下程序能求出满足条件:

1*1+2*2+......+n*n<

=1000中的

最大的n。

输出:

n=13

intn,s;

s==n=0;

while(s>

1000)

++n;

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

s=n*n;

n=%d\n"

n-1);

s=n=0;

s=0,n=0;

s=0,n=0;

n=s=0;

s=0;

n=0;

while(s<

=1000)

while(1000>

=s)

s+=n*n;

s=s+n*n;

s=s+n*n;

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

第1题(20.0分)

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

【程序设计】

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

编写函数fun其功能是:

根据整型形参m,计算如下

公式的值:

y=1+1/3+1/5+1/7+…+1/(2m+1)

若m=9,则应输出:

2.133256

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

floatfun(intm)

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

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

intmain()

intn;

Entern:

"

&

\nTheresultis%1f\n"

fun(n));

}

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

doubley=1;

for(i=1;

i<

=m;

i++)

{y+=1.0/(2*i+1);

return(y);

第2题(20.0分)

不使用字符串strlen函数,编写函数fun求一个字符串的长度,在main函数中

输入字符串,并输出其长度。

intfun(char*p1)

char*p,a[20];

intlen;

p=a;

pleaseinputastring:

\n"

gets(p);

len=fun(p);

Thestring'

slengthis:

%d\n"

len);

char*p;

intn=0;

p=p1;

while(*p++)

n++;

returnn;

模拟试题二

要求输出如下结果:

A,B

65,66

chara,【?

a=【?

b='

b'

;

a=a-32;

b=b-【?

%c,%c\n%d,%d\n"

a,b,a,b);

b

'

a'

97

32

编写一个程序,从键盘接收一个字符串,然后按照字符顺

序从小到大进行排序,并删除重复的字符。

string.h>

charstr[100],*p,*q,*r,c;

Inputastring:

gets(str);

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

for(p=【?

*p;

p++)

/****risthebiggestcharatmoment***/

for(q=r=p;

*q;

q++)

if(*r>

*q)

r=q;

if(r!

=p)/***swap*rand*p***/

c=*r;

*p=c;

for(p=str;

for(q=p;

*p【?

】*q;

q++);

strcpy(p+1,q);

Output:

%s\n\n"

【?

】);

str

*r=*p

==

计算正整数num的各位上的数字之积。

若输入:

252,则输出应该是:

20。

若输入:

202,则输出应该是:

0。

longfun(longnum)

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

longk=1

do

{

k*=num%10;

num\=10;

}while(!

num);

return(k);

main()

{

longn;

Pleaseenteranumber:

);

%ld"

n);

\n%ld\n"

fun(n));

longk=1;

num/=10;

}while(num);

}while(num!

=0);

利用条件运算符的嵌套来完成此题:

学习成绩>

=90分的同

学用A表示,70-89分之间的用B表示,60-69分之间的用C表示,

60分以下的用D表示。

intscore;

char*grade;

pleaseinputascore\n"

score);

if(score<

0&

score>

100)

超出范围!

switch(score)

grade='

A'

B'

C'

caseelse:

D'

}

%dbelongsto%c\n"

score,grade);

chargrade;

scanf("

score);

switch(score/10)

default:

case0:

case1:

case2:

case3:

case4:

case5:

编写函数fun(),要求从字符串中删除指定的字符(区分大、小)。

若程序执行时输入字符串为:

turbocandborlandc++

从键盘上输入字符:

n,则输出后变为:

turbocadbo

rladc++,如果输入的字符在字符串中不存在,则字

符串照原样输出。

voidfun(chars[],intc)

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

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

voidmain()

staticcharstr[]="

turbocandborlandc++"

charch;

原始字符串:

%s\n"

str);

输入一个字符:

%c"

ch);

fun(str,ch);

str[]=%s\n"

str);

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

char*q=s;

for(;

*q;

q++)

if(*q!

=c)*(s++)=*q;

*s=0;

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

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

当前位置:首页 > 党团工作 > 入党转正申请

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

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