#define STNUM 3 //学生数
struct student{
char id[10]
char name[10]
float course[3]
}
int main(){
student st[STNUM] //student结构体数组
int i,j
printf("==========录入信息==========\n")
for(i=0i<STNUMi++){
printf("请输入第%d个学生的信息\n",i+1)
printf("请输入学号:")
scanf("%10s",&st[i].id)
printf("请输入姓名:")
scanf("%10s",&st[i].name)
printf("请输入3门课的成绩:")
for(j=0j<3j++){
scanf("%f",&st[i].course[j])
sum[i] += st[i].course[j]
}
}
printf("==========学生信息==========\n")
for(i=0i<STNUMi++){
printf("-----------学生%d----------\n",i+1)
printf("学号:%s\n",st[i].id)
printf("姓名:%s\n",st[i].name)
printf("3门课的成绩:")
for(j=0j<3j++){
printf("%.1f ",st[i].course[j])
sum[i] += st[i].course[j]
}
printf("\n")
}
return 0
}
enum WeekDay {Monday=0, Tuesday, Wednesday, Thursday, Friday, Staturday, Sunday}char *name[] = { "Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
"Sunday"
}
typedef struct date
{
int year
int month
int day
enum WeekDay weekday
}date
int main()
{
date d
printf("Day: ")fflush(stdout)
scanf("%d",&d.day)
printf("Month: ")fflush(stdout)
scanf("%d",&d.month)
printf("Year: ")fflush(stdout)
scanf("%d",&d.year)
if ((d.month == 1) || (d.month == 2)){
d.month += 12
d.year--
}
d.weekday = (WeekDay)((d.day + 2*d.month + 3*(d.month+1)/5 + d.year + d.year/4 - d.year/100 + d.year/400) % 7)
printf("%d-%d-%d is %s.\n",d.year, d.month, d.day, name[d.weekday])
return 0
}
其中的公式参考:
http://www.cppblog.com/qywyh/articles/14021.html
希望能解决你的问题
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)