全国计算机C语言二级上机试题10套7180Word文档格式.docx
- 文档编号:20633819
- 上传时间:2023-01-24
- 格式:DOCX
- 页数:30
- 大小:20.99KB
全国计算机C语言二级上机试题10套7180Word文档格式.docx
《全国计算机C语言二级上机试题10套7180Word文档格式.docx》由会员分享,可在线阅读,更多相关《全国计算机C语言二级上机试题10套7180Word文档格式.docx(30页珍藏版)》请在冰豆网上搜索。
fprintf(myf,"
%c"
c);
fclose(myf);
printf("
if(fun(sfname,tfname))printf("
Succeed!
"
elseprintf("
Fail!
0000000000000000000000000
voidfun(longs,long*t)
{intd;
longsl=1;
*t=0;
while(s>
0)
{d=s%10;
/************found************/
if(d%2=0)
{*t=d*sl+*t;
sl*=10;
s\=10;
{longs,t;
\nPleaseenters:
scanf("
%ld"
&
s);
fun(s,&
t);
Theresultis:
%ld\n"
t);
00000000000000000
voidfun(inta,intb,long*c)
{
NONO()
{/*本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。
*/
FILE*rf,*wf;
inti,a,b;
longc;
rf=fopen("
C:
\\WEXAM\\YS240001\\in.dat"
"
r"
);
wf=fopen("
\\WEXAM\\YS240001\\out.dat"
"
for(i=0;
i<
10;
i++){
fscanf(rf,"
%d,%d"
a,&
b);
fun(a,b,&
c);
fprintf(wf,"
a=%d,b=%d,c=%ld\n"
a,b,c);
fclose(rf);
fclose(wf);
{inta,b;
longc;
Inputa,b:
b);
c);
c);
NONO();
72
#defineN8
typedefstructlist
{intdata;
structlist*next;
}SLIST;
SLIST*creatlist(int*);
voidoutlist(SLIST*);
intfun(SLIST*h)
{SLIST*p;
ints=0;
p=h->
next;
while(p)
{
s+=p->
___1___;
p=p->
___2___;
returns;
{SLIST*head;
inta[N]={12,87,45,32,91,16,20,48};
head=creatlist(a);
outlist(head);
\nsum=%d\n"
fun(___3___));
SLIST*creatlist(inta[])
{SLIST*h,*p,*q;
h=p=(SLIST*)malloc(sizeof(SLIST));
for(i=0;
N;
i++)
{q=(SLIST*)malloc(sizeof(SLIST));
q->
data=a[i];
p->
next=q;
p=q;
next=0;
returnh;
voidoutlist(SLIST*h)
if(p==NULL)printf("
ThelistisNULL!
else
{printf("
\nHead"
do
->
%d"
p->
data);
while(p!
=NULL);
End\n"
000000000000000000
string.h>
intfun(char*s,char*t1,char*t2,char*w)
char*p,*r,*a;
strcpy(w,s);
while(*w)
{p=w;
r=t1;
while(r)
if(*r==*p){r++;
p++;
elsebreak;
if(*r=='
\0'
)
{a=w;
r=t2;
while(*r){
*a=*r;
a++;
r++
w+=strlen(t2);
elsew++;
chars[100],t1[100],t2[100],w[100];
\nPleaseenterstringS:
%s"
s);
\nPleaseentersubstringt1:
t1);
\nPleaseentersubstringt2:
t2);
if(strlen(t1)==strlen(t2)){
fun(s,t1,t2,w);
\nTheresultis:
%s\n"
w);
Error:
strlen(t1)!
=strlen(t2)\n"
00000000000000000000
voidfun(char*s,chart[])
chars[100],t[100];
inti;
s);
fun(s,t);
%s\n"
t);
chars[100],t[100];
fun(s,t);
\nTheresultis:
73
#defineN4
fun(intt[][N],intn)
{inti,sum;
___1___;
n;
sum+=___2___;
sum+=t[i][n-i-___3___];
returnsum;
{intt[][N]={21,2,13,24,25,16,47,38,29,11,32,54,42,21,3,10},i,j;
\nTheoriginaldata:
{for(j=0;
j<
j++)printf("
%4d"
t[i][j]);
%d"
fun(t,N));
000000000000000
math.h>
doublefunx(doublex)
{return(2*x*x*x-4*x*x+3*x-6);
doublefun(doublem,doublen)
intr;
r=(m+n)/2;
while(fabs(n-m)<
0.001)
{if(funx(r)*funx(n)<
0)m=r;
elsen=r;
returnr;
main()
{doublem,n,root;
Entermn:
\n"
%lf%lf"
&
m,&
n);
root=fun(m,n);
root=%6.3f\n"
root);
0000000000000000000
voidfun(char*a,char*h,char*p)
NONO()
FILE*in,*out;
chars[81],*t,*f;
in=fopen("
out=fopen("
fscanf(in,"
t=f=s;
while(*t)t++;
t--;
while(*t=='
*'
)t--;
while(*f=='
)f++;
fun(s,f,t);
fprintf(out,"
fclose(in);
fclose(out);
{chars[81],*t,*f;
Enterastring:
gets(s);
fun(s,f,t);
Thestringafterdeleted:
puts(s);
74
structstudent{
longsno;
charname[10];
floatscore[3];
};
__1__fun(structstudenta)
{inti;
a.sno=10002;
strcpy(__2__,"
LiSi"
for(i=0;
3;
i++)__3__+=1;
returna;
{structstudents={10001,"
ZhangSan"
95,80,88},t;
\n\nTheoriginaldata:
\nNo:
%ldName:
%s\nScores:
"
s.sno,s.name);
i++)printf("
%6.2f"
s.score[i]);
t=fun(s);
\nThedataaftermodified:
t.sno,t.name);
t.score[i]);
00000000000000
#defineN20
fun(int*a,intn,intx)
{intp=0,i;
a[n]=x;
while(x!
=a[p])
p=p+1;
if(P==n)return-1;
{for(i=p;
i<
i++)
a[i+1]=a[i];
returnn-1;
{intw[N]={-3,0,1,5,7,99,10,15,30,90},x,n,i;
n=10;
Theoriginaldata:
i++)printf("
%5d"
w[i]);
\nInputx(todelete):
x);
Delete:
%d\n"
x);
n=fun(w,n,x);
if(n==-1)printf("
***Notbefound!
***\n\n"
Thedataafterdeleted:
#defineN16
typedefstruct
{charnum[10];
ints;
}STREC;
intfun(STREC*a,STREC*b)
{STRECs[N]={{"
GA05"
85},{"
GA03"
76},{"
GA02"
69},{"
GA04"
85},
{"
GA01"
91},{"
GA07"
72},{"
GA08"
64},{"
GA06"
87},
GA015"
GA013"
GA012"
GA014"
91},
GA011"
GA017"
GA018"
GA016"
72}};
STRECh[N];
inti,n;
FILE*out;
n=fun(s,h);
The%dlowestscore:
n);
%s%4d\n"
h[i].num,h[i].s);
%d\n"
%4d\n"
h[i].s);
fclose(out);
75
#defineN5
typedefstructnode{
intdata;
structnode*next;
}NODE;
__1__*fun(NODE*h)
{NODE*p,*q,*r;
p=h;
if(p==NULL)
returnNULL;
q=p->
next=NULL;
while(q)
r=q->
__2__;
next=p;
p=q;
q=__3__;
returnp;
NODE*creatlist(inta[])
{NODE*h,*p,*q;
h=NULL;
{q=(NODE*)malloc(sizeof(NODE));
if(h==NULL)h=p=q;
else{p->
next=q;
voidoutlist(NODE*h)
{NODE*p;
p=h;
{NODE*head;
inta[N]={2,4,6,8,10};
\nTheoriginallist:
head=fun(head);
\nThelistafterinverting:
#defineN80
{inti,j=0;
strlen(s);
/***********found**********/
if(i%2&
&
s[i]%2==0)
t[j++]=s[i];
t[i]='
{chars[N],t[N];
\nPleaseenterstrings:
gets(s);
t);
voidfun(ints[][10],intb[],int*n,intmm,intnn)
/*以下代码仅供参考*/
inti,j,np=0;
/*np用作b数组下标*/
nn;
*n=np;
{/*请在此函数内打开文件,输入测试数据,调用fun函数,输出数据,关闭文件。
inti,j,k;
intw[10][10],a[100],n=0,mm,nn;
for(k=0;
k<
5;
k++){
%d%d"
mm,&
nn);
mm;
for(j=0;
j<
j++)fscanf(rf,"
w
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 全国计算机 语言 二级 上机 试题 10 7180