全国计算机二级C机试题库_第1页
全国计算机二级C机试题库_第2页
全国计算机二级C机试题库_第3页
全国计算机二级C机试题库_第4页
全国计算机二级C机试题库_第5页
已阅读5页,还剩194页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1.±aDzO-Eyfun,o-EypA1|AUEQ:.u^YOOIA1«Ei^i^jEEas,MlEa^axux-i-ta°-EyOp-p»

0;nl"^DI21z«Ee;£

S=l+1/(1+2)+1/(1+2+3)+j-+1/(1+2+3+j-+n)

AyE?,EonpAOptallE±,o-EypAdpia1.833333j£

xida:2i-OO,3iDd,03dEQlAi£

Cei3,A3I-main0-Ey0lffiaEu0-EyODpAEi0iAUEY,^b6u0-EyfunpA»"A-0AODiiEeEu

±aD'pAEo,EOi^a,£

EOia3IDd:

♦include<conio.h>

#include<stdio.h>

♦include<string.h>

#include<stdlib.h>

floatfun(intn)

)

voidmain()

(

FILE*wf;

intn;

floats;

system(nCLSH);

printf("\nPleaseenterN:");

scanf("%d",&n);

s=fun(n);

printf("Theresultis:%f\n”,s);

/**********★**************★★★**/

wf=fopen("out.dat",Hwn);

fprintf(wf,"%f”,fun(11));

fclose(wf);

/*****************************/

)

飞。,比

floatfun(intn)

(

intizsl=0;

floats=0.0;

for(i=l;i<=n;i++)

(

sl=sl+i;

s=s+l.0/sl;

)

returns;

)

2.Qe±aD,d»,bo-Eyvoidfun(char*tt,int

pp[]),I3^OUttx0-u,®dD"a"p^"z"26.6xOA.,^-x63oI0pA,lEy,2<:OA,t•AoUppE

uO^EyxeOD।£

AyE?,p±EaEexd•u"©abcdefghabcdeabc06,3ifidpAEa3d^a1u6|.AEQ:333221

110000000000000000000

x«Oa:2i-OO-3iDd.03dE<?iA[£

Cei3,A3I-main0-Ey0IffiaEu0-EyODpAEi0iAUEY,ilb6u0-EyfunpA»"A-0AdDiiEeEu

laD^pAEo.EOi^aiE

E6ia3tDd:

#include<conio.h>

#include<stdio.h>

ttinclude<stdlib.h>

voidfun(char*ttzintpp[])

(

)

voidmain()

(

FILE*wf;

charaa[1000];

intbb[26],k;

system("CLSH);

printf("\nPleaseenteracharstring:");

scanf("%s",aa);

fun(aa,bb);

for(k=0;k<26;k++)

printf(H%d”,bb[k]);

printf(n\n");

/★********★*★**************★★**/

wf=fopen("out.datn,nwn);

fun("abcdefgabcdeabc”,bb);

for(k=0;k<26;k++)

nH

fprintf(wfz%d,bb[k]);

fclose(wf);

/*********★★******************/

)

,ij

voidfun(char*ttzintpp[])

inti;

for(i=0;i<26;i++)

pp[i]=0;

for(;*tt!=*\01;tt++)

ifa'*z1)

pp[*tt-,a,]++;

)

z13z2

3.Qe±aD°-Eyfun,EiipA;AUEQ:Q6ossEud,xO•u®0D0431><0-upA4dEyz-p»0

zEO|ii£

z3

AyEQzEoEaEexO•u@123412132,EaEe^O-ulzOdEad3।£

2Z33

x<:Oa:c-OO1©0500£<;1^|£

-ooo-oc>o

QeidiASlmain-EyIjEaEuEy0£)pAEiiAUEY,4b6u-EyfunpA»"A"A0DiiEeELi

iaD^AEo.EOi^ait

EOia3IDd:

#include<conio.h>

#include<stdio.h>

#include<stdlib.h>

#defineM81

intfun(char*ss,charc)

(

)

voidmain()

(

FILE*wf;

chara[M],ch;

system(“CLS“);

printf(n\nPleaseenterastring:");

gets(a);

printf("XnPleaseenterachar:H);

ch=getchar();

printf(n\nThenumberofthecharis:%d\n”,fun(arch));

/★*★*****★★★**************★****/

wf=fopen(Hout.dat",HwH);

fprintf(wf,n%dn,fun(“123412132",'1'));

fclose(wf);

/*********★★★************★★★★*/

)

[犷九/飞。,

intfun(char*ss,charc)

inti=0;

for(;*ss!=*\01;ss++)

if(*ss==c)

i++;

returni;

13。-3

4.Qe±aD'0»,b°-Eyfun,EtipA[AUEQ:Q6blp^m(1ni)0®AUAU±»7»dllSuypAEuO

1

DOuEy・AOUEyxeaOD,I**yn-p»0OaD©EypA4dEyj£

za33

AyEQ,E6«,0mpAOpt50f6dtDdEao:

711142122283335424449

X33

x<:Oa:-OOIDd40bEQlAi£

-o-oo-oo-o

Cei<3JATmainEyI^aEuEy0DpAEiiAUEY<^d0UEyfunpA»"A-A0DiiEeEu

±aD'pAEo,EOi^aj£

E6ia3IDd:

#include<conio.h>

#include<stdio.h>

#include<stdlib.h>

#defineM100

voidfun(intm,int*a,int*n)

(

}

voidmain()

(

FILE*wf;

intaa[M],n,k;

system(nCLSn);

fun(50,aa,&n);

for(k=0;k<n;k++)

3

if((k+1)%20==0)/*AeDDEab20AoEy*/

H

{printf(%4d"zaa[k]);

printf(H\nn);

)

else

H

printf(%4d"zaa[k]);

printf("\nH);

/**********★*******************/

wf=fopen("out.datn,HwH);

for(k=0;k<n;k++)

fprintf(wf,n%4dH,aa[k]);

fclose(wf);

/*****************************/

)

[切飞。,i±

voidfun(intm,int*a,int*n)

(

intizj=0;

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

if(i%7==0||i%ll==0)

a[j++]=i;

*n=j;

5.Qe±aD'o-Eyfun,JEa1;AUEQ:dA^t»EypAOyOuEya]tb012<:3E0»»bOuEy-A6

UcODi£°I2CpA・:^«aEypAE@I»°I,di»EyOA'I・AOUcEypAE®i»°IQ§t»Ei,bE

ypAE@I»°I,6I»EyOAI-AoUcEypA^ol»°I°UI»EIi£

AyEQ,口土a=45,b=12,p^-6A,Ao-Ey°6,c=5241\£

2Z33

x<:0a:c-OdiDdi0bEQlAi£

CetS.ASI-maino-EyoI^aEuo-Ey0£)pAEt°IAUEY,^b6uo-EyfunpA»"A"°AODtiEeEu

iaD^pAEo.EOi^ajL

EOIa3IDd:

#include<stdio.h>

#include<conio.h>

voidfun(inta,intbzlong*c)

(

)

voidmain()

(

inta,b;

longc;

FILE*out;

printf("Inputa,b:H);

scanf("%d%d”,&a,&b);

fun(a,b,&c);

printf("Theresultis:%ld\n'\c);

/女★★★★★★***★★★★****★★★★****★★★★/

nHn

out=fopen("out.datfw);

fun(a+11,b+22,&c);

n

fprintf(out,%ld\n"fc);

fclose(out);

}

j%2j&W,j之

voidfun(inta,intb,long*c)

{

*c=(a%10)*1000+(b%10)*100+(a/10)*10+b/10;

)

6.Ce±aD/o-Eyfun,EupA1lAUEQ^EEa:

s=(ln(l)+ln(2)+ln(3)+;-+ln(ni))a->a©0.5aa

OUCOiNOODeEp^-bAlog(n)°-EyC61n(n),£

AyEQ,EompAOpta20,Odfun0-EyOpta6.506583j£

xtda:2e-O6Z3iDd,03bEQlAi£

QeiS,AH-main°-EyoIjEaEuo-Ey0DpAEioiAUEY,iid6uo-EyfunpA»"A''oA0fiiiEeEu

iaD^AEo^Ebi^ait

EOIa3tDd:

♦include<conio・h>

♦include<stdio.h>

#include<math.h>

♦include<stdlib.h>

doublefun(intm)

)

voidmain()

(

FILE*wf;

system(”CLS“);

printf(n%f\nfun(20));

/1A1*****************************/

wf=fopen("out.dat",HwH);

nn

fprintf(wf,%fzfun(20));

fclose(wf);

/*****************************/

)

doublefun(intm)

(

inti;

doubles=0.0;

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

s=s+log(i);

returnsqrt(s);

)

O-123

7.±aD'Eyfun,EiipA;AUEQ:QonOOAU(»°uA-n)I-1E±AU±»5Oe1lOuypAEuODxQ

o2ao-

E»Eyd@tpA^-^iusz<:x4-IEyOp-p»0j£

a-a

AyE<?zni1000E±,°EyOpO|ts=96.979379i£

x,6含:2e-0dz3106,030£^1&1£

o-oo-oo,o

QeI5>A^rmainEyIjEaEuEy0£)pAEiiAUEY,^b6u-EyfunpA»"A'A0DiiEeEu

iaD^pAEo.EOi^aiE

EOia3IDd:

#include<conio.h>

♦include<math.h>

♦include<stdio.h>

#include<stdlib.h>

doublefun(intn)

voidmain()

(

FILE*wf;

system(nCLSH);

printf(Hs=%f\nn,fun(1000));

/******************************y

wf=fopen("out.dat“,"w");

fprintf(wf,n%fM,fun(1000));

fclose(wf);

/文*★*******★*****★*********★★★/

)

Wf-"

doublefun(intn)

{doubles=0.0;

inti;

for(i=0;i<n;i++)

if(i%5==0&&i%ll==0)

s=s+i;

s=sqrt(s);

returns;

)

8.Qe±aDzO-Eyfun,j£a1;AUEQ:h«EuOD'6601©iOUOuEympA-QE0Ey'aeEexxEuO,Eyx

1

eOD,•QE0EypA4oEyt"yk"«»0\£

3

AyEQzEaEe17zOdO|Ea646891012141516j£

金:2「06'配工工£

ooo-oo-o

QeIdiAqrmain-EyIJEaEuEy0DpAEiiAUEYz^b6uEyfunpA»"A"A0DiiEeEu

iaD^pAEo.EOi^aiE

EOIa3IDd:

#include<conio.h>

#include<stdio.h>

#include<stdlib.h>

voidfun(intm,int*k,intxx[])

(

)

voidmain()

(

FILE*wf;

intm,n,zz[100];

system(HCLSH);

printf(M\nPleaseenteranintegernumberbetween10and100:H);

scanf(n%dn,&n);

fun(n,&m,zz);

printf("\n\nThereare%dnon-primenumberslessthan%d:",m,n);

for(n=0;n<m;n++)

HH

printf(\n%4dfzz[n]);

/******************************y

wf=fopen("out.dat",HwH);

fun(17,&m,zz);

for(n=0;n<m;n++)

fprintf(wf,"%4d”,zz[n]);

fclose(wf);

/★★*******★★★************★***文/

)

voidfun(intm,int*k,intxx[])

(

inti,j,n=0;

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

{for(j=2;j<i;j++)

if(i%j==0)break;

if(j<i)xx[n++]=i;

)

*k=n;

)

±aD'o-Eyfun,EupA1;AUEQ:,u^YOOIA1«E^QoppAOp,1uOE°-EyOp'0»0i£m6ent

dOyEyqddaQ6m>n,£P=m!/(n!(m-n)!),AyEQ,m=12,n=8E±,OEDD^a1uIa495.

000000;£

xida:2i-OO,3iDd,03dEQlAi£

Cei3,A3I-main0-Ey0lffiaEu0-EyODpAEi0iAUEY,^b6u0-EyfunpA»"A-0AODiiEeEu

±aD'pAEo,EOi^a,£

E6±a3IDd:

♦include<conio.h>

#include<stdio.h>

♦include<stdlib.h>

floatfun(intm,intn)

(

)

voidmain()

(

FILE*wf;

system(nCLSn);

Hn

printf(p=%f\nzfun(12,8));

/******************************/

wf=fopen("out.dat",HwH);

fprintf(wf,H%f",fun(12,8));

fclose(wf);

/★★★★*****★★★****★★★*****★★★★文/

)

i%2露才0。,比

floatfun(intm,intn)

(

inti;

doublep=l.0;

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

p=p*i;

for(i=l;i<=n;i++)

p=p/i;

for(i=l;i++)

p=p/i;

returnp;

)

56±30»,0°-Eyfloatfun(double

h),o-EypA1;AUEQ:SIO±aAehODpAOp±£A6A^i»DiEy,2<:HOpUEyi»^0DDEAEataEe(1

aeSfhODpAOpta0yEy)j£

AyEQzE6h

aaaao-

Opt8.32433zOd°-Ey-p»08.32;E6hOpt8.32533,0dEy-p»08.33j£

x<:Oa:2c-O0z

ooo-oo-o

QeIdiAqrmain-EyIjEaEuEy0DpAEiiAUEYz^b6uEyfunpA»"A"A0DiiEeEu

iaD^pAEo.EOi^aiE

EOia3IDd:

#include<stdio.h>

♦include<conio.h>

#include<stdlib.h>

floatfun(floath)

(

)

voidmain()

(

FILE*wf;

floata;

system(HCLSH);

printf("Entera:n);

scanf("V,&a);

printf("Theoriginaldatais:H);

printf(n%f\n\nH,a);

printf("Theresult:%f\n",fun(a));

/**********★*******************/

wf=fopen("out.dat",nwH);

fprintf(wf,”,fun(8.32533));

fclose(wf);

/**★**************************/

}

i%214力。/士

floatfun(floath)

(

longt;

t=(h*10004-5)/10;

return(float)t/100;

z13aa-

Qe±aD°-Eyfun,°-EypA|AUEQ:Qod1It>I->EyxeOU±BOE0O®°Izx4-I°EyOp-p»0

i£5^I^EyxeODpAdpOUO^-°-EyO£),36ej£

AyEQ,E6^It>i-.EyxeODpAOpia

13579

29994

69998

13570

Od°-EyOpta61i£

金:2「06'配工工£

ooo-oo-o

QeIdiAqrmain-EyIJEaEuEy0DpAEiiAUEYz^b6uEyfunpA»"A"A0DiiEeEu

iaD^pAEo.EOi^aiE

EOia3IDd:

#include<conio.h>

#include<stdio.h>

#include<stdlib.h>

#defineM4

#defineN5

intfun(inta[M][N])

(

)

voidmain()

(

FILE*wf;

intaa[M][N]={{1,3,5,7,9},{2,9,9,9,4},{6,9,9,9,8},{l,3,5,7,0}};

inti,j,y;

system(nCLSH);

printf("Theoriginaldatais:\nn);

for(i=0;i<M;i++)

{for(j=0;j<N;j++)

printf("%6dn,aa[i][j]);

printf(H\nn);

)

y=fun(aa);

printf(n\nThesun:%d\n”,y);

printf(H\nH);

/******************************/

wf=fopen("out.dat",HwH);

fprintf(wf,"%d”,y);

fclose(wf);

/*****************************/

)

intfun(inta[M][N])

(

inti,j,sum=0;

for(i=0;i<M;i++)

for(j=0;j<N;j++)

if(i==0||i==M-l||j==0||j==N-l)

sum=sum+a[i][j];

returnsum;

)

±aDO-Eyftin,EiipA1;AUEQ:AuOAOOIAEuE^pA^dp¥puzu•--Qo-^^cos(x)-x=0

pAO»,dEp,ui£

xn+l=cos(xn)

puzu2^0eEQlA:

(1)Ejxl3odpta0.0;

3

(2)xO=xlz°NxlpAOp,,0x0;

(3)xl=cos(xO),Q63bO»,dDApAxl;

z2

(4)E6xO-xl,pA^0SIOOpDiOUO.000001z0d0DD^0e(5),-nOdO^D^e(2);

3a

(5)EuQ6xl^IEQ-^tcos(x)-x=0pAO»4bEp,u,^-gyOp-p»0j£

3IDd^«Ea3b^a1uRoot=0.739085i£

2z33

xCOa:e-OOIDd40bEQlAi£

-0-00-00-0

QeidJATmainEyI£aEuEyODpAEIiAUEY,^dOUEyfunpA»-A-AODiiEeEu

iaD^AEo.EOi^ajE

EOIa3if)d:

#include<stdio.h>

#include<conio.h>

♦include<math.h>

floatfun()

(

)

main()

(

FILE*out;

floatf=fun();

Mn

printf(Root=%f\nzf);

/******************************/

out=fopen(nout.dat",nw");

fprintf(out,”%f”,f);

fclose(out);

/*****************************★I

)

floatfun()

(

floatxl=0.0,xO;

do

x0=xl;

xl=cos(xO);

}while(fabs(xO-xl)>=le-6);

returnxl;

MU^'EaEepAxO-u,®ODO»°u°-,xOA,0I*°Ai£Qe±aD,o-Eyfun,EUpA1|AUEQ:ii«xo-u

'©ODpAQ°vm*°AE«2iE^3y,ODMa°t06A®)JA*°A2»«为3y;£

AyEQ,E6x0-ux®0DpAAUEYIa****A*BC*DEF*G*******,E^3y°6,xQ-u^DpAAUEY

6d6;p±ECA*BC*DEF*G*******i£

xtda:2i-OO-3tfid.03dEQlAi£

Qei3.A^-main0-Ey0IffiaEu0-EyODpAEi0iAUEY,hb6u0-EyfunpA»"A-0AODiiEeEu

±aD"pAEo,EOi^ai£

E6ia3IDd:

ttinclude<stdio.h>

#include<conio.h>

voidfun(char*a)

(

)

voidmain()

(

FILE*wf;

nn

chars[81]zt[81]=****A*BC*DEF*G*******;

printf("Enterastring:\nH);

gets(s);

fun(s);

printf("Thestringafterdeleted:\nn);puts(s);

/1A1*****************************/

wf=fopen("out.dat",HwH);

fun(t);

fprintf(wf,H%sn,t);

fclose(wf);

/*****************************/

)

voidfun(char*a)

(

char*p=a;

while(*p==1*1)

P++;

for(;*p!=1\01;p++,a++)

*a=*p;

*a=,\0,;

)

O-o-1Za-

Qe±aD'Eyfun,,AEypA;AUEQ:ADTIxO・C@EQ•nI»0IAfEdECOd°Ey・p»01,

04-o-Ey0DEa3bHYES”,-nOd-p»00,0-?°-EyODEa3bHNOn\£»0IAEQO,E3SlAolp1(区中7

O»NupAxO-u'®i£

AyEQ,xQ•uz@LEVELEQ»0tA,^0xQ-u'©123312^12»Eq»0IA\£

X,6含:2「。6'3珀6,036配的]£

,ooo-ooo

Ceid4Ajrmain-EyIjEaEuEy0£)pAEiiAUEY,^b6u-EyfunpA»"A"A0DiiEeEu

土立£TpA它6,i£

EOia3iDd:

♦include<stdio.h>

#defineN80

intfun(char*str)

(

)

main()

(

chars[N];

FILE*out;

char*test[]={”1234321“,“123421“,”123321”,“abcdCBA"};

inti;

printf("Enterastring:");

gets(s);

printf("\n\nH);

puts(s);

if(fun(s))

printf(HYES\nn);

else

printf(HN0\nn);

/★★★★★*****★★★*****★★★****★★★★****★★★/

out=fopen(nout.daf\HwH);

for(i=0;i<4;i++)

if(fun(test[i]))

fprintf(out,nYES\nn);

else

fprintf(out,nNO\nn);

fclose(out);

/************************************/

)

飞。

intfun(char*str)

inti,n=0,fg=l;

char*p=str;

while(*p)

{

n++;

P++;

)

for(i=0;i<n/2;i++)

if(str[i]==str[n-l-i]);

else

(

fg=0;

break;

)

returnfg;

)

o-z

Ce±a0»idEyfun(char*s)z;AUEC°NxO-u@ODpAAUEYAaedAi£

zzao-za

AyEQ,xQ.-Q(g)ODO-6DpAxO'U®iabcdefg<Oop^-OA,AEy06,@ODpAAUEYtgfeci

cbai£

2z33

x<:Oa:c-00iDd40dEQlAi£

-o_oo-oo-,o

Cei<3iATmainEyijEaEuEy0£)pAEiiAUEY,^b0UEyfunpA»"A'A0BiiEeEu

iaD^AEo.EOi^aj£

EOia3iDd:

#include<string.h>

#include<conio.h>

#include<stdio.h>

#defineN81

voidfun(char*s)

(

)

main()

(

chara[N];

FILE*out;

printf(nEnterastring:;

gets(a);

printf("Theoriginalstringis:H);

puts(a);

fun(a);

printf("\nn);

printf(HThestringaftermodified:H);

puts(a);

H

strcpy(az"HelloWorld!);

fun(a);

out=fopen("out・dat“,“w");

H

fprintf(out,%s"za);

fclose(out);

/★★★★★****★★★*****★★★★★★****★★*I

)

i%21j/3。,ij

voidfun(char*s)

(

charch;

int

i=0;

m=n=strlen(s)-1;

while(i<(n+l)/2)

(

ch=s[i];

s[i]=s[m];

s[m]=ch;

i++;

m——;

}

)

o-1zaa2

Ce±aD-d»ibEyfunrEiipA;AUEQ:^«d»,bEyxdxO-Q®x»»ib»idOQEy(»pAp^

OACOiNOIa匕«x。・C'®xala0uEypAo-Ey)\£

zHnaa

AyEQzEdEaEexO-u®-1234z6d°~Ey°NEux»»IOQEyOp-1234j£

2z33

x<:Oa:c-OdtDdA0d^QiAi£

-ooo-oo-,o

CeidiASImain-EyIjEaEuEy6DpAEtIAUEYz^b6uEyfunpA»"A'A0DIiEeEu

iaD^AEo.EOi^ajE

EOIa3if)d:

#include<stdio.h>

#include<string.h>

longfun(char*p)

(

)

voidmain()

(

FILE*wf;

chars[6];

longn;

printf("Enterastring:\n");

gets(s);

n=fun(s);

nH

printf(%ld\nrn);

/★★★★★★★★★★★★★***★*★**★*★★★****/

wf=fopen("out.dat","w");

fprintf(wf,fun(”-1234”));

fclose(wf);

/★★★★****★★★★*★*★*★★★*****★★★★I

}

i%2jjW,jt

longfun(char*p)

(

longn=0;

intflag=l;

if(*p==,-1)

{p++;flag=-1;}

elseif(*p==1+1)

P++;

while(*p!=*\01

{n=n*10+*p-101;

P++;

}

returnn*flag;

)

z

Qe±aD0»5b°-Eyvoidfun(char

1zaaaZZ

*ss)^a.|AUEC:^«xO-u@ssODEti6DiA±eI^Eyi»OAEipAxdAix»»i6D(Ed,

22a

Ai»OAEi»E(;xOAi,0d»x»»)j£

AyEQ,E6EaEeabc4EFg,Odd|Ea3baBc4EFgi£

2Z33

x<:0a:c-OdiDdi0bEQlAi£

ooo-oo-o

Cei5iASI-main-EyI^aEuEy0£)pAEtiAUEYz^b6uEyfunpA»"A"A0DiiEeEu

z

±a£)pAEo5EOi^aj£

EOIa3IDd:

#include<conio.h>

♦include<stdio.h>

♦include<string.h>

voidfun(char*ss)

)

voidmain()

chartt[51];

FILE*out;

printf("Pleaseenterancharacterstringwithin50characters:\nn);

gets(tt);

Hn

printf(\n\nAfterchanging,thestring\n%sztt);

fun(tt);

printf(n\nbecomes\n%sn,tt);

/★★★★****★★★★*★*★*★★★*****★★★**/

out=fopen(Hout.datH,nw");

strcpy(tt,"Afterchangingthestring**);

fun(tt);

Hn

fprintf(out,%sztt);

fclose(out);

/★★★★****★★★★****★★★★****★★★★★★/

)

飞。,比

voidfun(char*ss)

(

inti,n=0;

char*p=ss;

while(*p)

(

n++;

p++;

)

for(i=0;i<n;i++)

if((ss[i]>=,a,&&ss[i]<=,z,)&&i%2!=0)

ss[i]=ss[i]-32;

ss[i]=1\01;

)

,-o-33aZ3

±aDd»1d°Ey,,AEycEd0l^O»,dn^IEI2pAxQ-ui©OUAid*,oxQ-u®ODbiO

pAzIEy।£AyEQ,"EaEepAxO•uZ®Iaasdasasdfgasdaszx67asd

mklo,xQxQ-uz@Iaas,OdOIp±Ea3b6,£

x<:Oa:-OOZ3IDd,03dE?IAi£

CeI5,A3|-maino-EyoijEaEuo-EyC®pAEIoiAUEY,^60Uo-EyfunpA»"A"oA0BiiEeEu

±afi'pAEo,EOi^ai£

EOia3iDd:

♦include<conio.h>

#include<stdio.h>

#include<string.h>

ttinclude<stdlib.h>

intfun(char*str,char*substr)

{

}

voidmain()

(

FILE*wf;

charstr[81],substr[3];

intn;

system(nCLSH);

printf(nEaEeO^xO-uz<§>:n);

gets(str);

printf("EaEex6xO-uz®:");

gets(substr);

puts(str);

puts(substr);

n=fun(str,substr);

,,n

printf(n=%d\nzn);

/★★★★****★★★★*★*★*★★★******★★★*/

wf=fopen("out.dat",HwH);

n=ftin(nasdasasdfgasdaszx67asdmklon,"asH);

HH

fprintf(wf,%dzn);

fclose(wf);

/*****************************/

)

intfun(char★str,char*substr)

(

intizj=0;

for(i=0;str[i+1]!=*\01;i++)

if(str[i]==substr[0]&&str[i+1]==substr[1])

j++;

returnj;

±aD'O»,do-Ey,z6z«EepAnum.bxO-u0D003bxi3npAO»,dxO-uz®,2<:t"1yDI2IO.O

zza

emax«»0sA@p0O•(6A****xi^aE0EaEepA±eO^);£

x«Oa:2i-OO-3iDd.03dE<?IAi£

Qei3,A3I-main0-Ey0IffiaEu0-EyODpAEi0iAUEY,ilb6u0-EyfunpA»"A-0AdDiiEeEu

laD^pAEo.EOi^aiE

EOta3IDd:

#include<conio.h>

#include<stdio.h>

#include<string.h>

#include<stdlib.h>

char*fun(char(*a)[81],intnum,char*max)

(

)

voidmain()

(

FILE*wf;

charss[10][81],*ps=NULL;

chars[3][81]={”abcd“,“deg“,"diegns”},*p=NULL;

inti=0,n;

system(nCLSH);

printf(nEaEeE6,E,dxQ-uz®£on);

gets(ss[i]);

puts(ss[i]);

while(!strcmp(ss[i],H****")==0)/*6A4,dD(;oAx4-ia^aE0EaEepA±eO^*/

(

i++;

gets(ss[i]);

puts(ss[i]);

}

n=i;

ps=fun(ss,n,ps);

printf(”\nmax=%s\n",ps);

/**********★**************★★★**/

wf=fopen("out.dat",Hwn);

p=fun(s,3,p);

nn

fprintf(wf,%szp);

fclose(wf);

/**************************★**/

)

i%2曳力力。,工

char*fun(char(*a)[81],intnum,char*max)

(

inti=0;

max=a[0];

for(i=0;i<num;i++)

if(strlen(max)<strlen(a[i]))

max=a[i];

returnmax;

)

xo-121o-

±aDd»4dEyfun,EupA|AUEQ:EpIOA^,bxQ•u^@pAA-«^6(»E0AeaEystrcat

),,‘°Np2EuO,pAxQ-uz@A-i^6p^p1Eu0,pA^O•uz©06i£

z

AyE<;z•0±6EaEeiAA«A^4bx0-u®:

FirstString

SecondString

6d3IDdEa3d:

FirstStringSecondString

xeOa:2s^Dd^^EQlAjE

-ooo-oo-o

QeidiA^main-EyIjEaEuEy0£)pAEitAUEYz^b6uEyfunpA»"A"A0DiiEeEu

iaD^AEo.EOi^ait

EOia3IDd:

#include<stdio.h>

#include<conio.h>

#include<stdlib.h>

voidfun(charpl[],charp2[])

(

)

voidmain()

(

FILE*wf;

charsi[80],s2[40];

charpl[80]=nFirstStringn,p2[40]=nSecondstringH;

system("CLSH);

printf(nEntersiands2:\nn);

scanf("%s%s",si,s2);

printf(nsl=%s\nn,si);

printf("s2=%s\n",s2);

printf("Invokefun(sl,s2):\n");

fun(si,s2);

printf("Afterinvoking:\n");

nn

printf(%s\nzsl);

I★★★

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论