- 1、本文档共8页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
宁波大学实验报告
学号
姓名
专业 土木建设类 5 班
学院 阳明学院
2016 年 6 月 10 日
实验名称:结构体与链表
实验目的与要求:
掌握结构体类型变量的定义和使用。
掌握结构体类型数组的定义和使用。
掌握利用结构和指针处理单向链表的方法
完成实验教材规定的内容,提交实验报告。
实验内容与实验结果: (注明题号,并给出准确、全面的答案)
程序完整题
#include<> struct
{
int year; int month; int day; }date; void main()
{
int i,days;
int day_tab[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
printf("Input year,month,day:");
scanf("%d,%d,%d",&,&,&;
days=0;
for(i=1;i<;i++)
days+=day_tab[i];
days+=;
if>2&&%4==0&&%100!=0||%400==0))
days+=1;
printf("%d/%d is the %dth day in %d",,,days,;
}
程序改写题
#include<> struct
{
int year; int month; int day; }date;
int main()
{
int days(int year,int month,int day);
int day_sum;
printf("Input year,month,day:");
scanf("%d,%d,%d",&,&,&;
day_sum=days,,;
printf("%d/%d is the %dth day in %d",,,day_sum,;
return 0;
}
int days(int year,int month,int day)
{
int sum=0,i;
int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
for(i=1;i<month;i++)
{
sum=sum+a[i];
}
sum=sum+day;
if((year%1==0&&year%100!=0||year%400==0)&&month>=3)
{
sum+=1;
}
return sum;
}
一般编程题(1)
#include<>
struct z
{
char a[30];
int r;
};
void main()
{
struct z z1={"通信工程 ",32},z2={" 电子信息科学与工程 ",35},z3={" 自动化 ",44},z4={" 光电
信息工程 ",28};
printf("%s 专业,报名人数 %d\n",,;
printf("%s 专业 ,报名人数 %d\n",,;
printf("%s 专业 ,报名人数 %d\n",,;
printf("%s 专业 ,报名人数 %d\n",,;
}
2)
#include ""
#include <>
#define SIZE 3
struct student
{
int score[3];
float average;
} stud[SIZE]; void input()
{
int i; for(i=0;i<SIZE;i++)
{
printf(" 第 %d 个学生的成绩 :\n",i+1);
scanf("%d%d%d",&stud[i].score[0],&stud[i].score[1],&stud[i].score[2]);
}
}
void calaverage()
{
int i;
for(i=0;i<SIZE;i++)
{
stud[i].average=(stud[i].score[0]+stud[i].score[1]+stud[i].score[2])/;
}
}
void sortput()
{
int i,j;
struct student temp;
for(i=0;i<SIZE;i++)
{
for(j=0;j<SIZE-i-1;j++)
{
if(stud[j].average<stud[j+1].average)
temp=stud[j];
stud[j]=stud[j+1];
stud[j+1]=temp;
}
}
}
void output()
{
int i;
printf("\n");
for(i=0;i<SIZE;i++)
printf("%d %d %d %\n",stud[i].score[0],stud[i].score[1],stud[i].score[2],stud[i].average);
}
您可能关注的文档
- (人教新课标)三级品德与社会下册教案家人的爱.docx
- -学西师版二年级数学下册教学计划.docx
- -新路径英语小学四年级英语下册期中试卷.docx
- -西城区初二语文期末试题及答案.docx
- 0910月自学考试《中国当代文学作品选》试题.docx
- 12时辰养生对照表.docx
- 13汽车仪表与警报装置.docx
- 15.1两种电荷导学案教案.docx
- 16.1电压学案教案.docx
- 16秋西交《证据法学》在线作业满分答案.docx
- AUTOSAR_SWS_OS电子行业标准.pdf
- AUTOSAR_SWS_NVRAMManager电子行业标准.pdf
- r20ut3766ej0100_rfp电子行业标准.pdf
- AUTOSAR_SWS_SAEJ1939NetworkManagement电子行业标准.pdf
- AUTOSAR_SWS_PlatformTypes电子行业标准.pdf
- AUTOSAR_SWS_WatchdogDriver电子行业标准.pdf
- AUTOSAR_SWS_WirelessEthernetDriver电子行业标准.pdf
- AUTOSAR_TR_TimingAnalysis电子行业标准.pdf
- Continental_AUTOSAR Center电子行业标准.pdf
- EB_AUTOSAR Tooling in practice电子行业标准.pdf
文档评论(0)