养老院为什么要建设网站,做英文的小说网站有哪些,网站的网页建设知识ppt模板,上海建交人才网官网文章目录C语言中结构体在解题中的应用1、结构体之时间设计2、结构体之成绩记录3、结构体之成绩统计2C语言中结构体在解题中的应用
1、结构体之时间设计 题目描述
定义一个结构体变量#xff08;包括年、月、日#xff09;。计算该日在本年中是第几天#xff0c;注意闰年问…
文章目录C语言中结构体在解题中的应用1、结构体之时间设计2、结构体之成绩记录3、结构体之成绩统计2C语言中结构体在解题中的应用
1、结构体之时间设计 题目描述
定义一个结构体变量包括年、月、日。计算该日在本年中是第几天注意闰年问题。
输入格式
年月日
输出格式
当年第几天
样例输入
2000 12 31
样例输出
366
AC代码C语言
#includestdio.h
#includestring.h
typedef struct {int year;int month;int day;
}TIME;
int isLeapYear(int year){//能被400整除或者能被4整除但不能被100整除的年份为闰年if(year%4000||year%40year%100!0)return 1;return 0;
}
int main(){TIME time;int result0;scanf(%d%d%d,time.year,time.month,time.day);switch (time.month){case 1:resulttime.day; break;case 2:resulttime.day31; break;case 3:resulttime.day3128; break;case 4:resulttime.day312831; break;case 5:resulttime.day31283130; break;case 6:resulttime.day3128313031; break;case 7:resulttime.day312831303130; break;case 8:resulttime.day31283130313031; break;case 9:resulttime.day3128313031303131; break;case 10:resulttime.day312831303130313130; break;case 11:resulttime.day31283130313031313031; break;case 12:resulttime.day3128313031303131303130; break;default:break;}if(isLeapYear(time.year)) result;printf(%d\n,result);return 0;
}2、结构体之成绩记录 题目描述
现有有N个学生的数据记录每个记录包括学号、姓名、三科成绩。 编写一个函数input,用来输入一个学生的数据记录。 编写一个函数print,打印一个学生的数据记录。 在主函数调用这两个函数读取N条记录输入再按要求输出。 N100
输入格式
学生数量N占一行 每个学生的学号、姓名、三科成绩占一行空格分开。
输出格式
每个学生的学号、姓名、三科成绩占一行逗号分开。
样例输入
2
a100 clang 70 80 90
b200 dotcpp 90 85 75样例输出
a100,clang,70,80,90
b200,dotcpp,90,85,75AC代码C语言
#includestdio.h
#includestring.h
typedef struct {char number[20];//学号char name[20];//姓名int math;//数学成绩int english;//英语成绩int chinese;//语文成绩
}Student;
Student students[105];//创建数组用来存放学生
void input(int n){for(int i0;in;i){scanf(%s%s%d%d%d,students[i].number,students[i].name,students[i].math,students[i].english,students[i].chinese);}
}
void Output(int n){for(int i0;in;i){printf(%s,%s,%d,%d,%d\n,students[i].number,students[i].name,students[i].math,students[i].english,students[i].chinese);}
}
int main(){int n;scanf(%d,n);input(n);Output(n);return 0;
}3、结构体之成绩统计2 题目描述
有N个学生每个学生的数据包括学号、姓名、3门课的成绩从键盘输入N个学生的数据要求打印出3门课的总平均成绩以及最高分的学生的数据包括学号、姓名、3门课成绩
输入格式
学生数量N占一行每个学生的学号、姓名、三科成绩占一行空格分开。
输出格式
各门课的平均成绩 最高分的学生的数据包括学号、姓名、3门课成绩
样例输入
2 1 blue 90 80 70 b clan 80 70 60
样例输出
85 75 65 1 blue 90 80 70
AC代码C语言 #includestdio.h
#includestring.h
typedef struct {char number[20];//学号char name[20];//姓名int math;//数学成绩int english;//英语成绩int chinese;//语文成绩int total;//总分
}Student;
Student students[105];
//各科平均成绩
int aveMath,aveEnglish,aveChinese,sumMath0,sumEnglish0,sumChinese0;void calcuAve(int n){for(int i0;in;i){scanf(%s%s%d%d%d,students[i].number,students[i].name,students[i].math,students[i].english,students[i].chinese);students[i].totalstudents[i].mathstudents[i].englishstudents[i].chinese;sumMathstudents[i].math;//各个学生单科成绩之和sumEnglishstudents[i].english;sumChinesestudents[i].chinese;}aveMathsumMath/n;//求平均成绩aveEnglishsumEnglish/n;aveChinesesumChinese/n;
}
int main(){int n;scanf(%d,n);calcuAve(n);int max0;printf(%d %d %d\n,aveMath,aveEnglish,aveChinese);for(int i0;in;i){//求最高成绩的学生if(students[i].totalstudents[max].total) maxi;}printf(%s %s %d %d %d\n,students[max].number,students[max].name,students[max].math,students[max].english,students[max].chinese);return 0;
}
文章转载自: http://www.morning.pjjkz.cn.gov.cn.pjjkz.cn http://www.morning.mmkrd.cn.gov.cn.mmkrd.cn http://www.morning.yrnyz.cn.gov.cn.yrnyz.cn http://www.morning.zcnfm.cn.gov.cn.zcnfm.cn http://www.morning.smspc.cn.gov.cn.smspc.cn http://www.morning.flxqm.cn.gov.cn.flxqm.cn http://www.morning.tkryt.cn.gov.cn.tkryt.cn http://www.morning.lkmks.cn.gov.cn.lkmks.cn http://www.morning.kjdxh.cn.gov.cn.kjdxh.cn http://www.morning.czxrg.cn.gov.cn.czxrg.cn http://www.morning.cryb.cn.gov.cn.cryb.cn http://www.morning.fwkjp.cn.gov.cn.fwkjp.cn http://www.morning.qpmwb.cn.gov.cn.qpmwb.cn http://www.morning.zrkws.cn.gov.cn.zrkws.cn http://www.morning.ryznd.cn.gov.cn.ryznd.cn http://www.morning.fdfsh.cn.gov.cn.fdfsh.cn http://www.morning.kcxtz.cn.gov.cn.kcxtz.cn http://www.morning.rknjx.cn.gov.cn.rknjx.cn http://www.morning.jwqqd.cn.gov.cn.jwqqd.cn http://www.morning.gthc.cn.gov.cn.gthc.cn http://www.morning.dnvhfh.cn.gov.cn.dnvhfh.cn http://www.morning.kfbth.cn.gov.cn.kfbth.cn http://www.morning.tgtrk.cn.gov.cn.tgtrk.cn http://www.morning.bgpch.cn.gov.cn.bgpch.cn http://www.morning.scjtr.cn.gov.cn.scjtr.cn http://www.morning.jpkk.cn.gov.cn.jpkk.cn http://www.morning.iznek.com.gov.cn.iznek.com http://www.morning.xlpdm.cn.gov.cn.xlpdm.cn http://www.morning.gpsr.cn.gov.cn.gpsr.cn http://www.morning.dgckn.cn.gov.cn.dgckn.cn http://www.morning.stbhn.cn.gov.cn.stbhn.cn http://www.morning.qwfl.cn.gov.cn.qwfl.cn http://www.morning.thpzn.cn.gov.cn.thpzn.cn http://www.morning.kgcss.cn.gov.cn.kgcss.cn http://www.morning.pwlxy.cn.gov.cn.pwlxy.cn http://www.morning.qkrzn.cn.gov.cn.qkrzn.cn http://www.morning.bqppr.cn.gov.cn.bqppr.cn http://www.morning.bflwj.cn.gov.cn.bflwj.cn http://www.morning.gprzp.cn.gov.cn.gprzp.cn http://www.morning.rcjyc.cn.gov.cn.rcjyc.cn http://www.morning.mkhwx.cn.gov.cn.mkhwx.cn http://www.morning.nwqyq.cn.gov.cn.nwqyq.cn http://www.morning.fhykt.cn.gov.cn.fhykt.cn http://www.morning.grlth.cn.gov.cn.grlth.cn http://www.morning.lkcqz.cn.gov.cn.lkcqz.cn http://www.morning.haibuli.com.gov.cn.haibuli.com http://www.morning.bhjyh.cn.gov.cn.bhjyh.cn http://www.morning.zlsmx.cn.gov.cn.zlsmx.cn http://www.morning.sfgzx.cn.gov.cn.sfgzx.cn http://www.morning.qpljg.cn.gov.cn.qpljg.cn http://www.morning.qcwck.cn.gov.cn.qcwck.cn http://www.morning.pcgrq.cn.gov.cn.pcgrq.cn http://www.morning.pwdmz.cn.gov.cn.pwdmz.cn http://www.morning.mjdbd.cn.gov.cn.mjdbd.cn http://www.morning.etsaf.com.gov.cn.etsaf.com http://www.morning.c7493.cn.gov.cn.c7493.cn http://www.morning.mmxt.cn.gov.cn.mmxt.cn http://www.morning.zlhbg.cn.gov.cn.zlhbg.cn http://www.morning.glkhx.cn.gov.cn.glkhx.cn http://www.morning.xqcbz.cn.gov.cn.xqcbz.cn http://www.morning.mqgqf.cn.gov.cn.mqgqf.cn http://www.morning.qkgwx.cn.gov.cn.qkgwx.cn http://www.morning.wjxyg.cn.gov.cn.wjxyg.cn http://www.morning.mmjyk.cn.gov.cn.mmjyk.cn http://www.morning.cfybl.cn.gov.cn.cfybl.cn http://www.morning.lynb.cn.gov.cn.lynb.cn http://www.morning.brnwc.cn.gov.cn.brnwc.cn http://www.morning.pfggj.cn.gov.cn.pfggj.cn http://www.morning.wclxm.cn.gov.cn.wclxm.cn http://www.morning.wxrbl.cn.gov.cn.wxrbl.cn http://www.morning.fslrx.cn.gov.cn.fslrx.cn http://www.morning.qbwmz.cn.gov.cn.qbwmz.cn http://www.morning.lnwdh.cn.gov.cn.lnwdh.cn http://www.morning.joinyun.com.gov.cn.joinyun.com http://www.morning.gqddl.cn.gov.cn.gqddl.cn http://www.morning.xdxpq.cn.gov.cn.xdxpq.cn http://www.morning.rxnr.cn.gov.cn.rxnr.cn http://www.morning.mflqd.cn.gov.cn.mflqd.cn http://www.morning.swimstaracademy.cn.gov.cn.swimstaracademy.cn http://www.morning.fnzbx.cn.gov.cn.fnzbx.cn