C考试题Word格式文档下载.docx

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

C考试题Word格式文档下载.docx

《C考试题Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《C考试题Word格式文档下载.docx(27页珍藏版)》请在冰点文库上搜索。

C考试题Word格式文档下载.docx

处理后的字符产在主函数中输出。

Iamastudent.

string.h>

voidfunc(chars[],intn)

inti,j;

for(i=0;

i<

=n;

i++)

if(s[i]>

='

A'

&

s[i]<

Z'

)s[i]=s[i]+32;

chars[100];

gets(s);

intn;

n=strlen(s);

func(s,n);

puts(s);

3.

将十个任意音乐符号变换,变换规则:

1->

6;

2->

5;

3->

4;

4->

3;

5->

2;

6->

1;

7->

7。

十个原始数据由键盘输入。

输出变换结果。

1156765432

6621712345

inta[10],i,c,d;

10;

scanf("

a[i]);

switch(a[i]){

case1:

printf("

%d"

6);

break;

case2:

5);

case3:

4);

case4:

3);

case5:

2);

case6:

1);

case7:

7);

}

\n"

);

4

编写函数voidfunc(char*ps2,constchar*ps1)将字符串一中序数是奇数且ASCII吗为奇数的字符保留,否则为空格,串1最大长度为20;

返回新的字符串2.比如在main中调用func函数出力“Jabavhga”的结果。

为:

str2=g

voidfunc(char*ps2,constchar*ps1)

inti,j=0,n;

n=strlen(ps1);

n;

if(((i+1)%2!

=0)&

(ps1[i]%2!

=0))

*(ps2+j++)=*(ps1+i);

else*(ps2+j++)='

'

;

*(ps2+j)='

\0'

chars[]={"

Jabavhga"

},a[20]={'

};

func(a,s);

str2="

puts(a);

5

向文本文件in.dat中写入一行文本,然后将文件内容反响显示。

helloworld!

dlrowolleh

voidmain()

FILE*a,*b;

chars[1000];

inti,n;

a=fopen("

in.txt"

"

w"

n=strlen(s);

fputs(s,a);

fclose(a);

b=fopen("

for(i=0;

i++)

fputc(s[n-i-1],b);

6

6使用头插法创建包含5个结点的单链表,输出链表中的第二个元素。

链表结点的形式如下:

TypedefstructtagNode{

Intdata;

structtagNode*next;

}LNode,*linklist;

//LNode为单链表结构类型,LinkList为单链表指针类型

12345

stdlib.h>

typedefstructtagNode{

intdata;

structtagNode*next;

}LNode,*LinkList;

LinkLists,head;

intn=5;

head=(LinkList)malloc(sizeof(LNode));

for(;

n>

0;

n--)

s=(LinkList)malloc(sizeof(LNode));

s->

data);

s->

next=head->

next;

head->

next=s;

head->

next->

7

验证谷角猜想:

n);

%d->

"

n);

n!

=2;

if(n%2==0){n=n/2;

else{n=n*3+1;

1\n"

8

输入一个人3行4列的整形数组的值,输出最大元素的值及其下标。

123456789101112

max:

a[2][3]=12

inta[3][4];

inti,j,t,m=0,n=0;

a[i][j]);

t=a[0][0];

if(a[i][j]>

t)

t=a[i][j];

m=i;

n=j;

a[%d][%d]=%d\n"

m,n,t);

9

键入一个学生10门课的成绩,找出最高分和平均成绩,输出二者之差的结果。

56677898776668858666

98-74.90=23.10

inta[10];

inti,j,max,sum=0;

doubleave,k;

i++)scanf("

max=a[0];

sum=sum+a[i];

if(a[i]>

max)max=a[i];

ave=sum/10.0;

k=max-ave;

%d-%.2lf=%.2lf\n"

max,ave,k);

10.

编写函数voidfunc(char*ps2,constchar*ps1)删除字符串一中序数是偶数且ASCII吗为偶数的字符,串1最大长度为20;

str2=Jabavga

str2=Jabavga

if(((i+1)%2==0)||(ps1[i]%2!

11.

从键盘键入3行文本,并在每行文本最前面加上4位行号和一个空格。

helloworld

HelloC

Thisisafile

0001helloworld

0002HelloC

0003Thisisafile

chars[3][1000],s1[3][1000];

inti;

gets(s[0]);

gets(s[1]);

gets(s[2]);

b.c"

sprintf(s1[i],"

%04d%s\n"

i+1,s[i]);

fputs(s1[i],a);

12.

使用尾插法创建包含5个结点的单链表,输出链表中的第3个结点前插入元素3进行遍历输出链表中每个结点的数据域信息。

12456

123456

LinkListhead,p0,p1,s;

data=3;

head=p0=(LinkList)malloc(sizeof(LNode));

p1=(LinkList)malloc(sizeof(LNode));

p1->

p0->

next=p1;

p0=p1;

next=NULL;

p1=head;

for(n=1;

n<

=3;

n++)

if(n!

=3)p1=p1->

else{s->

next=p1->

while(p1->

next!

=NULL)

p1->

p1=p1->

13.

编写函数voidfunc(char*ps2,constchar*ps1)删除字符串一中序数是奇数且ASCII吗为偶数的字符,串1最大长度为20;

str2=aahga

14.

已知有三个书记的销售记录,每个销售记录有代码(charc【5】),书名(charn【11】)单价(intp),数量(intq)四个部分组成。

1001软件世界5100

1002计算机工程6120

1003程序设计8200

将每个销售记录写入out.dat文件中,然后将第二个记录输出

charb[99];

structbook{

charc[5];

charn[11];

intp;

intq;

}a[3];

for(i=0;

scanf("

%s%s%d%d"

a[i].c,&

a[i].n,&

a[i].p,&

a[i].q);

FILE*out;

out=fopen("

out.txt"

{sprintf(b,"

%s%s%d%d\n"

a[i].c,a[i].n,a[i].p,a[i].q);

fputs(b,out);

%s%s%d%d\n"

a[1].c,a[1].n,a[1].p,a[1].q);

fclose(out);

15.

使用头插法创建包含5个结点的单链表,输出链表中的第3个结点后遍历输出链表中每个结点的数据域信息。

5421

}LNode,*Linklist;

Linklisthead,p0,p1;

head=(Linklist)malloc(sizeof(LNode));

p0=(Linklist)malloc(sizeof(LNode));

p0->

next=p0;

p0=head;

next=p0->

p0=p0->

p0->

16

设计一个函数fan求如下分段函数的值。

要求在主函数中输入x的值,在主函数中输出y的值

y=xx<

1

2x-11<

=x<

10

3x-1110<

=x

-10

doublefan(doublex)

if(x<

1)return(x);

10&

x>

=1)return(2*x-1);

if(x>

=10)return(x*3-11);

doublex,y;

%lf"

x);

y=fan(x);

%.0lf\n"

y);

17

迭代法求x=sqrt(a),求平方根的迭代公式x=(1/2)(x+a/x),x的初值为一。

循环条件为前后两次求出x的差的绝对值小于10e-6.

2

1.414214

math.h>

doublex1,x0=1;

inta;

a);

x1=(1.0/2.0)*(x1+a/x0);

do

x0=x1;

x1=(1.0/2.0)*(x0+a/x0);

}while(fabs(x1-x0)>

10e-6);

%.06lf\n"

fabs(x1));

18

输出1到50之间能被3正处,不能被5整除的正整数。

36912182124273336394248

inti,x;

for(i=1;

=50;

if(i%3==0&

i%5!

=0)printf("

i);

升序拍好的数组(5,9,10,23,25)倒叙,并输出结果数组。

输出;

25231095

inta[5]={5,9,10,23,25},b[5],i;

b[i]=a[5-1-i];

b[i]);

19

使用尾插法创建包含5个结点的单链表,遍历输出链表中每个结点的数据域信息。

LinkListhead,p0,p1;

inti;

p0=head->

20

1到20之间最大的非素数。

max=20

inta[20]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};

inti,j,s,max=0;

20;

{s=a[i];

for(j=2;

s;

{if(s%j==0)

{if(max<

s)

{max=s;

}break;

}}

max);

21

输入图形的行数,打印出如下图形。

*

**

***

****

*****

intn,i,j;

n+1;

{for(j=1;

{if(j<

=n-i)

{printf("

"

else

*"

if(j==n)

22

输入10个数,从小到大尽兴排序。

97865432110

12345678910

voidsort(inta[],intn)

inti,j,s;

for(j=i+1;

{if(a[i]>

a[i]=a[j];

a[j]=s;

a[i]);

inta[10],i;

sort(a,10);

23

使用尾插法创建包含5个结点的单链表,输出2在链表中的位置。

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

当前位置:首页 > PPT模板 > 国外设计风格

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

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