ImageVerifierCode 换一换
格式:DOCX , 页数:13 ,大小:1.07MB ,
资源ID:17526418      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/17526418.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(C语言程序设计结构体实验报告Word格式.docx)为本站会员(b****3)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

C语言程序设计结构体实验报告Word格式.docx

1、n第%d位学生的基本信息如下:nn, i);学号:(%d)t姓名:(%s)t性别:(%c)t年龄:(%d)nn, stu-num, stu-name, stu-sex, stu-age);三科成绩:(%.2f,%.2f,%.2f)nnscore0, stu-score1, stu-score2);总成绩:(%.2f) 平均成绩:(%.2f)n, sum, aeg);n+n);int main() int i, n;The number of students is: scanf(%d, &n); struct Stu *stu = (struct Stu *)calloc(n, sizeof(

2、struct Stu); for (i = 0; inum);姓名:%s, (stu + i)-name);性别: %csex);年龄:%f%f%fscore0, &score1, & putchar(n =n fun(stu + i, i + 1); return 0;题目二:计算每一个结构体的两个变量所表示的长度之和(单位:厘米)要求:(1)分别定义公制METRIC(成员包括:米、厘米)和英制BRITISH(成员包括:英尺、英寸)两个结构体;(2)为每一个结构定义两个变量。 struct METRIC float m; float cm; m1, m2; struct BRITISH fl

3、oat foot; float inches; b1, b2;Enter the info of m1(米,厘米):%f%fm1.m, &m1.cm);Enter the info of m2(米,厘米):m2.m, &m2.cm);nEnter the info of m2(英尺,英寸):b1.foot, &b1.inches);Enter the info of m2(英尺,英寸):b2.foot, &b2.inches);nSum of m1 and m2 is:%.2f(厘米)n, (m1.m + m2.m) * 100 + m1.cm + m2.cm);Sum of b1 and b

4、2 is:%.2f(厘米)nn, (b1.inches + b2.inches)*30.48 + (b1.foot + b2.foot)*2.54);题目三:编写一个函数用于计算某个日期是相应年份的第几天声明一个描述日期(年、月、日)的结构体类型。struct time int year; int month; int day; ;void fun(struct time time) int a,b,sum=0; for(a=1;atime.month;a+) if(a=4|a=6|a=9|a=11) sum+=30; else if(a=2) if(time.year%4=0)&(time.

5、year%100!=0|time.year%400=0) sum+=29; else sum+=28; else sum+=31; sum+=time.day;%d-%d-%d 是该年的第 %d 天!,time.year,time.month,time.day,sum); struct time time;Enter the date(Example:xxxx xx xx)(End with 0000 00 00): while(scanf(%d%d%d,&time.year,&time.month,&time.day)!=EOF) if(time.year=0&time.month=0&ti

6、me.day=0) break; fun(time);题目四:定义两个函数分别用于输入和输出N个STUDENT结构体变量的信息定义两个结构体STUDENT和BIRTHDAY。 其中结构体STUDENT包含成员有:姓名(char name20),学号(int number),出生日期(BIRTHDAY birth);结构体BIRTHDAY包含的成员有:年份(int year),月份(int month)和日期(int day)。struct BIRTHDAY int year; int month; int day;struct STUDENT int number; struct BIRTHD

7、AY birth;void input(struct STUDENT *stu,int n) int i; putchar( i n;第 %d 位学生的信息:n姓名:, stui.name);stui.number);生日:%d-%d-%dstui.birth.year, &stui.birth.month, &stui.birth.day); if (i != n - 1) putchar( else printf(输入完毕!void output(struct STUDENT *stu, int n)n第 %d 位学生的信息如下:(%s)t学号:(%d)t生日:(%d-%d-%d)n, s

8、tui.name, stui.number, stui.birth.year, stui.birth.month, stui.birth.day);输出完毕! int n;请输入待输入资料的学生的数目N: struct STUDENT *stu = (struct STUDENT *)calloc(n, sizeof(struct STUDENT); input(stu, n);=n output(stu, n);题目五:函数sortInfo()是按照总成绩从高到低的顺序进行排序的。如果两位学生的总成绩相等,则按照学号从小到大排序。1声明一个STUDENT结构体,成员有:姓名(char nam

9、e20),学号(int number),总成绩(float totalScore)2在main函数中定义一个长度为N的结构体数组arr,调用函数sortInfo(struct STUDENT *arr, int n)对N位学生的信息进行排序 float totalScore;第 %d 位学生的基本信息:%fstui.totalScore);void sortInfo(struct STUDENT *stu, int n) int i,j; struct STUDENT temp; for (j = 1; j n - i; j+) if (stui.totalScore (stui + j.nu

10、mber) temp = stui; stui = stui + j; stui + j = temp; (%d)t总成绩:, stui.name, stui.number, stui.totalScore);排序之前的初始状态: sortInfo(stu, n);排序之后的最终状态:题目六:编程模拟一个时钟(时间实时更新)1声明一个时间结构体TIME,包含成员:时(int hour),分(int minute),秒(int second)。定义函数updata()用于更新时间。2假设当前时刻为23:59:59,则调用函数updata将得到的下一刻时间为00:00:00假设当前时刻为23:45

11、:56,则调用函数updata将得到的下一刻时间为23:57Windows.hstruct TIME int hour; int minute; int second;updata(struct TIME *t) if (t-second = 59) t-second = 0; if (t-minute = 59) t-minute = 0; if (t-hour = 23) t-hour = 0; else (t-hour)+; else (t-minute)+; else (t-second)+; struct TIME t;请设定此刻时钟的时间(XX:XX:XX):%d:t.hour,&t.minute,&t.second); while (1)%02d:%02dr, t.hour, t.minute, t.second); updata(&t); Sleep(1000);四、讨论

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1