c语言编程题Word文件下载.docx

上传人:b****5 文档编号:19421581 上传时间:2023-01-06 格式:DOCX 页数:18 大小:19.17KB
下载 相关 举报
c语言编程题Word文件下载.docx_第1页
第1页 / 共18页
c语言编程题Word文件下载.docx_第2页
第2页 / 共18页
c语言编程题Word文件下载.docx_第3页
第3页 / 共18页
c语言编程题Word文件下载.docx_第4页
第4页 / 共18页
c语言编程题Word文件下载.docx_第5页
第5页 / 共18页
点击查看更多>>
下载资源
资源描述

c语言编程题Word文件下载.docx

《c语言编程题Word文件下载.docx》由会员分享,可在线阅读,更多相关《c语言编程题Word文件下载.docx(18页珍藏版)》请在冰豆网上搜索。

c语言编程题Word文件下载.docx

2、编写main函数。

用给定的测试字符串s1与s2调用squeeze函数,将处理后的s1字符串与s3字符串保存到结果文件myf2、out中。

s1:

“abbcdefgghiijkl”,s2:

“bdglkw”

acefhiij,s3:

bbdggkl

myexamnumberis:

0112400123(本人准考证号)

4、编程题

1、编写函数char*insert(char*p),其功能就是:

在p指向的字符串中所有数字字符子串前插入一个符号’-’。

函数返回p字符串的首地址。

用给定的测试字符串初始化数组,调用insert函数对字符串做处理,将结果字符串保存到结果文件myf2、out中。

AB1CD12EF123GH

AB-1CD-12EF-123GH

5、编程题

1、编写函数voidfun(intarray[],intn),将array数组中的前n个整数按从大到小的顺序排序。

从键盘上输入一个正整数,求出该位就是几位数,按从左到右的顺序显示各位数字,用这些数字组成一个最小正整数(调用fun函数),将以上三项结果保存到结果文件myf2、out中。

6、编程题

1、编写函数fun,它的功能就是:

求出这N个学生的平均分,由函数值返回。

例如,若学生的成绩就是:

85,76,69,85,91,72,64,87,则平均分应当就是:

78、625

将N名学生的成绩在主函数中放入一个带头节点的链表结构中,h指向链表的头节点。

并调用函数fun,将结果及函数返回值写入到文件myf2、out中。

7、编程题

移动字符串中的内容,移动的规则如下:

把第1到第m个字符平移到字符串的最后,把第m+1到最后的字符串移动字符串的前部。

例如:

字符串中原有的内容为:

ABCDEFGHIJK,m的值为3,则移动后,字符串中的内容应该就是:

DEFGHIJKABC、

在main函数中初始化一个字符串,调用函数fun,将结果字符串及函数返回值写入到文件myf2、out中。

8、编程题

●【程序功能】

●以矩阵的行作为排序的交换单位,使得排序后的矩阵按指定列的元素值递减有序。

●【编程要求】

●1、编写函数voidsort(intx[][4],intn,intcol)。

它的功能就是:

对x指向的二维数组(该数组中保存了一个n*4矩阵)以行作为交换单位,按照下标为col的列元素值做递减排序。

●2、编写main函数。

声明一个3行4列二维数组并用测试数据初始化该数组,调用sort函数对该数组中保存的矩阵按第3列(列下标为2)排序,将排序后二维数组中的矩阵输出到屏幕并用写文件函数保存到结果文件myf2、out中。

●【测试数据与运行结果】

●测试数据(排序前):

●101806090

●102709050

●103607080

●运行结果(按第3列排序后):

●103607080

●myexamnumberis:

考生本人准考证号字符串

●【要求】

1、编程:

#include<

stdio、h>

stdlib、h>

ctype、h>

string、h>

intfindword(char*s,char*t,charch[][20])

{

chartmp[10][20];

intcn=0,i,count=0,j,m,n,len,lena;

while(*s)

{

while(!

isalpha(*s)&

&

*s)s++;

if(isalpha(*s)&

*s)

{

i=0;

while(isalpha(*s)&

{

tmp[cn][i++]=*s;

s++;

}

tmp[cn][i]=0;

cn++;

}

}

for(i=0;

i<

cn;

i++)

puts(tmp[i]);

len=strlen(t);

lena=strlen(tmp[i]);

for(j=0;

j<

lena;

j++)

for(m=j,n=0;

n<

len&

m<

n++,m++)

if(tmp[i][m]!

=t[n])break;

if(n>

=len)

strcpy(ch[count++],tmp[i]);

break;

returncount;

}

voidmain()

char*s="

Nolivingmanallthingscan、Graspall,loseall、"

*t="

all"

ch[10][20];

intn,i;

FILE*fp;

fp=fopen("

myf2、out"

"

w"

);

if(fp==0)

{printf("

can'

topenthisfile、"

exit(-1);

n=findword(s,t,ch);

n;

printf("

%s"

ch[i]);

fprintf(fp,"

printf("

\nwordsNO:

%d"

n);

fprintf(fp,"

\nmynois0002499999、"

fclose(fp);

2、编程:

voidjosephu(inta[],intb[],intn,intm)

inti=0,flag=1,cn=0;

while(cn<

n)

if(a[i]==0)

i=(i+1)%10;

elseif(flag<

3)

flag++;

elseif(flag==3)

b[cn++]=a[i];

a[i]=0;

flag=1;

intn,m,i,a[100],b[100];

entern,m:

"

scanf("

%d,%d"

&

n,&

m);

a[i]=i+1;

josephu(a,b,n,m);

%4d"

b[i]);

4d"

3、编程:

voidsqueeze(char*s1,char*s2,char*s3)

char*p,*q;

inti=0;

while(*s1)

p=s2;

while(*p&

*p!

=*s1)p++;

if(*p)

s3[i++]=*s1;

q=s1;

while(*q)

*q=*(q+1);

q++;

s1--;

s1++;

s3[i]=0;

char*s1="

abbcdefgghiijkl"

*s2="

bdglkw"

*s3="

;

squeeze(s1,s2,s3);

s1:

%s\n"

s1);

s3:

s3);

myexamenumberis0002499999、"

4、编程:

char*insert(char*p)

char*q=p,temp[20];

while(*p)

isalpha(*p))p++;

strcpy(temp,p);

*p++='

-'

strcpy(p,temp);

isdigit(*p))p++;

returnq;

char*p="

AB1CD12EF123GH"

*q;

q=insert(p);

%s"

q);

5、编程:

voidfun(intarray[],intn)

{

inti,j,t;

n-1;

for(j=i+1;

if(array[i]<

array[j])

{t=array[i];

array[i]=array[j];

array[j]=t;

inta[5]={0},m,n=0,i=0,min=0;

{printf("

t"

clrscr();

scanf("

%d"

if(m/10000!

=0)

n=5;

elseif(m/1000!

n=4;

elseif(m/100!

n=3;

elseif(m/10!

n=2;

else

n=1;

%dhas%dbits:

m,n);

%dhas%dbits、"

i=n-1;

while(m!

a[i--]=m%10;

m/=10;

a[i]);

fprintf(fp,"

\n"

fun(a,n);

while(i>

min=min*10+a[i];

i--;

minis%d"

min);

6、编程:

#defineN8

typedefstructslist

doublescore;

structslist*next;

}STREC;

STREC*creatlist(doubles[])

STREC*head,*p,*q;

head=p=(STREC*)malloc(sizeof(STREC));

p->

next=0;

while(i<

N)

q=(STREC*)malloc(sizeof(STREC));

q->

score=s[i];

p->

next=q;

p=q;

i++;

returnhead;

doublefun(STREC*h)

STREC*p;

doubleaver=0、0;

p=h->

next;

while(p)

aver+=p->

score/N;

p=p->

returnaver;

doubles[N]={85,76,69,85,91,72,64,87},aver;

STREC*head;

head=creatlist(s);

aver=fun(head);

cann'

topenthisfile"

exit(-1);

s[%d]:

%f\n"

i,s[i]);

%f"

s[i]);

aver=%f"

aver);

\naver=%f"

7、编程:

voidfun(char*s,intm)

inti=0,n=strlen(s);

chart[100]="

m)

t[i]=*(s+i);

for(i=m;

s[i-m]=s[i];

for(i=n-m;

s[i]=t[i-n+m];

intm;

topenthefile"

enters:

gets(s);

/*puts(s);

*/

enterm:

/*printf("

m);

fun(s,m);

puts(s);

s);

8、编程:

voidsort(intx[][4],intn,intcol)

intp,q,j,t,max,indx;

for(p=0;

p<

p++)

indx=p;

max=x[p][col];

for(q=p+1;

q<

q++)

if(x[q][col]>

max)

max=x[q][col];

indx=q;

4;

t=x[p][j];

x[p][j]=x[indx][j];

x[indx][j]=t;

intx[3][4]={{101,80,60,90},{102,70,90,50},{103,60,70,80}},i,j;

sort(x,3,2);

3;

printf("

x[i][j]);

fprintf(fp,"

mynois0002499999、"

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

当前位置:首页 > 小学教育 > 学科竞赛

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

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