C语言上机作业第十章Word格式文档下载.docx
- 文档编号:20767304
- 上传时间:2023-01-25
- 格式:DOCX
- 页数:15
- 大小:16.23KB
C语言上机作业第十章Word格式文档下载.docx
《C语言上机作业第十章Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《C语言上机作业第十章Word格式文档下载.docx(15页珍藏版)》请在冰豆网上搜索。
Zhanghua"
76.5,78.0,82.0};
floata;
scanf("
%f"
&
a);
modify(&
std,a);
show(std);
return0;
2.结构体填空2
string.h>
structstudent
longsno;
charname[10];
};
voidfun(structstudent*b)
b->
sno=10004;
strcpy(b->
name,"
LiJie"
intmain()
structstudentt={10002,"
ZhangQi"
{93,85,87}};
fun(&
t);
No:
%ldName:
%s\nScores:
"
t.sno,t.name);
for(i=0;
i++)printf("
%6.2f"
t.score[i]);
3.结构体填空3
structstudent{
voidfun(structstudenta[],intn)
structstudentt;
inti,j;
n-1;
for(j=i+1;
j<
n;
j++)
if(strcmp(a[i].name,a[j].name)>
0)
{t=a[i];
a[i]=a[j];
a[j]=t;
}
{structstudents[4]={{10001,"
ZhangSan"
{95,80,88}},{10002,"
LiSi"
{85,70,78}},{10003,"
CaoKai"
{75,60,88}},{10004,"
FangFang"
{90,82,87}}};
fun(s,4);
Thedataaftersorting:
for(j=0;
4;
{printf("
\nNo:
%-8sScores:
s[j].sno,s[j].name);
s[j].score[i]);
4.链表填空1
stdlib.h>
#defineN8
typedefstructlist
intdata;
structlist*next;
}SLIST;
SLIST*creatlist(int*a);
voidoutlist(SLIST*);
voidfun(SLIST*h,int*n)
SLIST*p;
*n=0;
p=h->
next;
while(p)
{
(*n)++;
p=p->
SLIST*head;
inta[N]={12,87,45,32,91,16,20,48},num;
head=creatlist(a);
outlist(head);
fun(head,&
num);
\nnumber=%d\n"
num);
SLIST*creatlist(inta[])
SLIST*h,*p,*q;
h=p=(SLIST*)malloc(sizeof(SLIST));
N;
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
\nHead"
do
->
%d"
p->
data);
while(p!
=NULL);
End\n"
5.链表填空2
SLIST*creatlist(int*);
intfun(SLIST*h)
ints=0;
s+=p->
data;
returns;
inta[N]={12,87,45,32,91,16,20,48};
sum=%d\n"
fun(head));
Head"
p->
6.链表填空3
SLIST*creatlist(char*);
intfun(SLIST*h,charch)
intn=0;
=0)
n++;
if(p->
data==ch)returnn;
elsep=p->
intk;
charch;
chara[N]={'
m'
'
p'
g'
a'
w'
x'
r'
d'
%c"
ch);
k=fun(head,ch);
if(k==0)printf("
Notfound!
elseprintf("
Thesequencenumberis:
%d\n"
k);
SLIST*creatlist(char*a)
\nThelistisNULL!
7.结构体编程1
#defineN16
charnum[10];
ints;
}STREC;
intfun(STREC*a,STREC*b,intl,inth)
inti,count=0;
16;
if(a->
s>
=l&
&
a->
s<
=h)
num,a->
s=a->
s;
b++;
count++;
a++;
returncount;
STRECs[N]={{"
GA005"
85},{"
GA003"
76},{"
GA002"
69},{"
GA004"
85},
{"
GA001"
96},{"
GA007"
72},{"
GA008"
64},{"
GA006"
87},
GA015"
GA013"
94},{"
GA012"
GA014"
91},
GA011"
90},{"
GA017"
GA018"
GA016"
72}
};
STRECh[N];
inti,n,low,heigh,t;
%d%d"
&
low,&
heigh);
if(heigh<
low)
t=heigh;
heigh=low;
low=t;
n=fun(s,h,low,heigh);
Thestudent'
sdatabetween%d--%d:
low,heigh);
%s%4d\n"
h[i].num,h[i].s);
8.结构体编程2
intfun(STREC*a,STREC*b)
inti,min,count=0;
min=a->
=min)
for(i=16;
i>
0;
i--)a--;
s==min)
s=min;
GA05"
GA03"
GA02"
GA04"
GA01"
91},{"
GA07"
GA08"
GA06"
inti,n;
getchar();
n=fun(s,h);
9.链表编程
structslist
doubles;
structslist*next;
typedefstructslistSTREC;
doublefun(STREC*h)
doublemax=0;
max=h->
if(max<
h->
s)max=h->
h=h->
}while(h!
=0);
returnmax;
STREC*creat(double*s)
STREC*h,*p,*q;
inti=0;
h=p=(STREC*)malloc(sizeof(STREC));
s=0;
while(i<
N)
q=(STREC*)malloc(sizeof(STREC));
s=s[i];
i++;
voidoutlist(STREC*h)
STREC*p;
head"
%2.0f"
s);
doubles[N]={85,76,69,85,91,72,64,87},max;
STREC*h;
h=creat(s);
outlist(h);
max=fun(h);
max=%6.1f\n"
max);
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 语言 上机 作业 第十
![提示](https://static.bdocx.com/images/bang_tan.gif)