vc++ 2Word文档下载推荐.docx
- 文档编号:7811848
- 上传时间:2023-05-09
- 格式:DOCX
- 页数:18
- 大小:17.19KB
vc++ 2Word文档下载推荐.docx
《vc++ 2Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《vc++ 2Word文档下载推荐.docx(18页珍藏版)》请在冰点文库上搜索。
voidmax(inttmp[])/*对数组进行排序*/
intmax;
max=tmp[0];
for(inti=0;
i<
3;
i++)/*4个数进行简单选择排序*/
intk=i;
for(intj=k+1;
j<
4;
j++)
{
if(tmp[j]>
tmp[k])
{max=tmp[j];
tmp[j]=tmp[k];
tmp[k]=max;
}
}
intcha(intb[])/*求差值*/
{
intx,y,z;
x=b[0]*1000+b[1]*100+b[2]*10+b[3];
/*x是四位组合的最大数*/
if(b[3]!
=0)/*四位数最高位不能为0*/
y=b[3]*1000+b[2]*100+b[1]*10+b[0];
/*x是四位组合的最小数*/
else
y=b[2]*1000+b[1]*10+b[0];
z=x-y;
returnz;
intmain()
intx;
x=cin_number();
do
inttmp[4];
inta,b,c,d,result;
a=x/1000;
b=(x-a*1000)/100;
c=(x-a*1000-b*100)/10;
d=x%10;
tmp[0]=a;
tmp[1]=b;
tmp[2]=c;
tmp[3]=d;
max(tmp);
result=cha(tmp);
cout<
result="
result<
x=result;
system("
pause"
);
}while
(1);
return0;
3好多人参加比赛,统计成绩。
36:
29
有7个评委,每个评委都要给选手打分,现在要求去掉一个最高分和去掉一个最低分,在算出平均分。
结果精确到小数点后两位。
输入
测试数据包括多个实例。
每组包括7个实数,代表评委们对该选手的评分。
紧接着是选手的名字,名字的长度不超过30个字符。
输入直到文件结束。
输出
算出每为选手名字和最终得分,结果保留两位小数。
样例输入
1010101010109xiaoyuanwang
0000000beast
样例输出
Xiaoyuanwang10.00
Beast0.00
源代码:
#include"
stdafx.h"
string>
classhappy
public:
happy()
请输入7个数据数据:
;
for(inti=0;
7;
i++)
cin>
a[i];
请输入被评议人姓名:
/*for(intj=0;
=30;
j++)
s1[j];
*/
s1;
voidpaixu()
floattmp=0.0;
6;
for(intj=0;
6-i;
if(a[j]>
a[j+1])
{
tmp=a[j];
a[j]=a[j+1];
a[j+1]=tmp;
}
a[0]=0.0;
a[6]=0.0;
voidoutput()
floatsum1=0.0;
sum1=sum1+a[i];
sum1=(sum1*1.0)/7;
s1<
'
'
sum1<
private:
floata[7];
strings1;
};
intn;
while((cin>
n)&
n!
=EOF)
happyh;
h.paixu();
h.output();
、打印以下矩阵:
01
***
*********
***************
**********************
intmain()
inth,tmp,m,n;
请输入一个奇数(菱形高度):
cin>
h;
请输入一个数(菱形矩阵高度):
m;
请输入一个数(菱形矩阵宽度):
n;
tmp=(h+1)/2;
for(intt=0;
t<
t++)
tmp;
for(intl=0;
l<
l++)
for(intj=tmp-i-1;
j>
=0;
j--)
{
cout<
"
}
for(intk=1;
k<
=(i*2+1);
k++)
*"
for(j=tmp-i-1;
}
}
for(i=tmp-1;
i>
i--)
for(intl=0;
l++)
{
for(intm=0;
m<
=tmp-i;
m++)
cout<
for(intn=0;
n<
=2*(i-1);
n++)
for(m=0;
(2)
用类来实现:
classlingxingjuzhen
lingxingjuzhen()
voidshixian()
tmp=(h+1)/2;
for(inti=0;
for(intl=0;
{
for(intj=tmp-i-1;
{
cout<
}
}
private:
n)
lingxingjuzhenl1;
l1.shixian();
标题:
Re2、打印以下矩阵:
39:
55
是这个图形
***
*********
***************
**********************
链表的实现
35:
09
stdio.h"
stdlib.h"
cmath>
//usingnamespacestd;
#defineNULL0
#defineLENsizeof(structstudent)
structstudent
longnum;
floatscore;
structstudent*next;
intn;
structstudent*creat()//creat
structstudent*head;
structstudent*p1,*p2;
n=0;
p1=p2=(structstudent*)malloc(LEN);
scanf("
%d,%f"
&
p1->
num,&
p2->
score);
head=NULL;
while(p1->
num!
=0)
n=n+1;
if(n==1)head=p1;
elsep2->
next=p1;
p2=p1;
p1=(structstudent*)malloc(LEN);
scanf("
%ld,%f"
next=NULL;
return(head);
voidprint(structstudent*head)//print
structstudent*p;
printf("
\nNow,These%drecordsare:
\n"
n);
p=head;
if(head!
=NULL)
do
printf("
%ld,%5.1f\n"
p->
num,p->
p=p->
next;
}while(p!
=NULL);
structstudent*del(structstudent*head,longnum)//del
if(head==NULL)
printf("
\nlistnul!
gotoend;
p1=head;
while(num!
=p1->
num&
next!
p1=p1->
if(num==p1->
num)
if(p1==head)head=p1->
else
p2->
next=p1->
delete:
%ld\n"
num);
n=n-1;
elseprintf("
%ldnotbeenfound!
end:
return(head);
}
structstudent*insert(structstudent*head,structstudent*stud)//insert
structstudent*p0,*p1,*p2;
p0=stud;
if(head==NULL)
head=p0;
p0->
else
while((p0->
num>
num)&
(p1->
=NULL))
p2=p1;
p1=p1->
if(p0->
num<
if(head==p1)head=p0;
else
p2->
next=p0;
p0->
else
p1->
n=n+1;
structstudent*head,*stu;
longdel_num;
inputrecodes:
head=creat();
print(head);
\ninputthedeletednumber:
%ld"
del_num);
while(del_num!
head=del(head,del_num);
print(head);
inputthedeletedrescord:
inputtheinsertedrescord:
stu=(structstudent*)malloc(LEN);
stu->
while(stu->
head=insert(head,stu);
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- vc+ vc
![提示](https://static.bingdoc.com/images/bang_tan.gif)